spi: synquacer: Disable clock in probe error path
commit5.4-rM2-2.2.x-imx-squashed8853b25030
upstream. If the calls to platform_get_irq() or devm_request_irq() fail on probe of the SynQuacer SPI driver, the clock "sspi->clk" is erroneously not unprepared and disabled. If the clock rate "master->max_speed_hz" cannot be determined, the same happens and in addition the spi_master struct is not freed. Fix it. Fixes:b0823ee35c
("spi: Add spi driver for Socionext SynQuacer platform") Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: <stable@vger.kernel.org> # v5.3+ Cc: Masahisa Kojima <masahisa.kojima@linaro.org> Link: https://lore.kernel.org/r/232281df1ab91d8f0f553a62d5f97fc264ace4da.1604874488.git.lukas@wunner.de Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
parent
4051e5b774
commit
cad189512c
|
@ -658,7 +658,8 @@ static int synquacer_spi_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
if (!master->max_speed_hz) {
|
if (!master->max_speed_hz) {
|
||||||
dev_err(&pdev->dev, "missing clock source\n");
|
dev_err(&pdev->dev, "missing clock source\n");
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto disable_clk;
|
||||||
}
|
}
|
||||||
master->min_speed_hz = master->max_speed_hz / 254;
|
master->min_speed_hz = master->max_speed_hz / 254;
|
||||||
|
|
||||||
|
@ -671,7 +672,7 @@ static int synquacer_spi_probe(struct platform_device *pdev)
|
||||||
rx_irq = platform_get_irq(pdev, 0);
|
rx_irq = platform_get_irq(pdev, 0);
|
||||||
if (rx_irq <= 0) {
|
if (rx_irq <= 0) {
|
||||||
ret = rx_irq;
|
ret = rx_irq;
|
||||||
goto put_spi;
|
goto disable_clk;
|
||||||
}
|
}
|
||||||
snprintf(sspi->rx_irq_name, SYNQUACER_HSSPI_IRQ_NAME_MAX, "%s-rx",
|
snprintf(sspi->rx_irq_name, SYNQUACER_HSSPI_IRQ_NAME_MAX, "%s-rx",
|
||||||
dev_name(&pdev->dev));
|
dev_name(&pdev->dev));
|
||||||
|
@ -679,13 +680,13 @@ static int synquacer_spi_probe(struct platform_device *pdev)
|
||||||
0, sspi->rx_irq_name, sspi);
|
0, sspi->rx_irq_name, sspi);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "request rx_irq failed (%d)\n", ret);
|
dev_err(&pdev->dev, "request rx_irq failed (%d)\n", ret);
|
||||||
goto put_spi;
|
goto disable_clk;
|
||||||
}
|
}
|
||||||
|
|
||||||
tx_irq = platform_get_irq(pdev, 1);
|
tx_irq = platform_get_irq(pdev, 1);
|
||||||
if (tx_irq <= 0) {
|
if (tx_irq <= 0) {
|
||||||
ret = tx_irq;
|
ret = tx_irq;
|
||||||
goto put_spi;
|
goto disable_clk;
|
||||||
}
|
}
|
||||||
snprintf(sspi->tx_irq_name, SYNQUACER_HSSPI_IRQ_NAME_MAX, "%s-tx",
|
snprintf(sspi->tx_irq_name, SYNQUACER_HSSPI_IRQ_NAME_MAX, "%s-tx",
|
||||||
dev_name(&pdev->dev));
|
dev_name(&pdev->dev));
|
||||||
|
@ -693,7 +694,7 @@ static int synquacer_spi_probe(struct platform_device *pdev)
|
||||||
0, sspi->tx_irq_name, sspi);
|
0, sspi->tx_irq_name, sspi);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "request tx_irq failed (%d)\n", ret);
|
dev_err(&pdev->dev, "request tx_irq failed (%d)\n", ret);
|
||||||
goto put_spi;
|
goto disable_clk;
|
||||||
}
|
}
|
||||||
|
|
||||||
master->dev.of_node = np;
|
master->dev.of_node = np;
|
||||||
|
@ -711,7 +712,7 @@ static int synquacer_spi_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
ret = synquacer_spi_enable(master);
|
ret = synquacer_spi_enable(master);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail_enable;
|
goto disable_clk;
|
||||||
|
|
||||||
pm_runtime_set_active(sspi->dev);
|
pm_runtime_set_active(sspi->dev);
|
||||||
pm_runtime_enable(sspi->dev);
|
pm_runtime_enable(sspi->dev);
|
||||||
|
@ -724,7 +725,7 @@ static int synquacer_spi_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
disable_pm:
|
disable_pm:
|
||||||
pm_runtime_disable(sspi->dev);
|
pm_runtime_disable(sspi->dev);
|
||||||
fail_enable:
|
disable_clk:
|
||||||
clk_disable_unprepare(sspi->clk);
|
clk_disable_unprepare(sspi->clk);
|
||||||
put_spi:
|
put_spi:
|
||||||
spi_master_put(master);
|
spi_master_put(master);
|
||||||
|
|
Loading…
Reference in New Issue