Skip to content

Commit 62bbc86

Browse files
Tobias Jordanbroonie
authored andcommitted
spi: pxa2xx: check clk_prepare_enable() return value
clk_prepare_enable() can fail, so its return value should be checked and acted upon. Found by Linux Driver Verification project (linuxtesting.org). Fixes: 3343b7a ("spi/pxa2xx: convert to the common clk framework") Signed-off-by: Tobias Jordan <Tobias.Jordan@elektrobit.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 6126fd8 commit 62bbc86

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/spi/spi-pxa2xx.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,9 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
16121612
}
16131613

16141614
/* Enable SOC clock */
1615-
clk_prepare_enable(ssp->clk);
1615+
status = clk_prepare_enable(ssp->clk);
1616+
if (status)
1617+
goto out_error_dma_irq_alloc;
16161618

16171619
master->max_speed_hz = clk_get_rate(ssp->clk);
16181620

@@ -1716,6 +1718,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
17161718
pm_runtime_put_noidle(&pdev->dev);
17171719
pm_runtime_disable(&pdev->dev);
17181720
clk_disable_unprepare(ssp->clk);
1721+
1722+
out_error_dma_irq_alloc:
17191723
pxa2xx_spi_dma_release(drv_data);
17201724
free_irq(ssp->irq, drv_data);
17211725

@@ -1789,8 +1793,11 @@ static int pxa2xx_spi_resume(struct device *dev)
17891793
int status;
17901794

17911795
/* Enable the SSP clock */
1792-
if (!pm_runtime_suspended(dev))
1793-
clk_prepare_enable(ssp->clk);
1796+
if (!pm_runtime_suspended(dev)) {
1797+
status = clk_prepare_enable(ssp->clk);
1798+
if (status)
1799+
return status;
1800+
}
17941801

17951802
/* Restore LPSS private register bits */
17961803
if (is_lpss_ssp(drv_data))
@@ -1819,9 +1826,10 @@ static int pxa2xx_spi_runtime_suspend(struct device *dev)
18191826
static int pxa2xx_spi_runtime_resume(struct device *dev)
18201827
{
18211828
struct driver_data *drv_data = dev_get_drvdata(dev);
1829+
int status;
18221830

1823-
clk_prepare_enable(drv_data->ssp->clk);
1824-
return 0;
1831+
status = clk_prepare_enable(drv_data->ssp->clk);
1832+
return status;
18251833
}
18261834
#endif
18271835

0 commit comments

Comments
 (0)