Commit bff892ac authored by Carlos Song's avatar Carlos Song Committed by Mark Brown

spi: spi-fsl-lpspi: remove redundant spi_controller_put call

devm_spi_alloc_controller will allocate an SPI controller and
automatically release a reference on it when dev is unbound from
its driver. It doesn't need to call spi_controller_put explicitly
to put the reference when lpspi driver failed initialization.

Fixes: 2ae0ab01 ("spi: lpspi: Avoid potential use-after-free in probe()")
Signed-off-by: default avatarCarlos Song <carlos.song@nxp.com>
Reviewed-by: default avatarAlexander Sverdlin <alexander.sverdlin@siemens.com>
Link: https://msgid.link/r/20240403084029.2000544-1-carlos.song@nxp.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a3d3eab6
...@@ -852,39 +852,39 @@ static int fsl_lpspi_probe(struct platform_device *pdev) ...@@ -852,39 +852,39 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
fsl_lpspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); fsl_lpspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(fsl_lpspi->base)) { if (IS_ERR(fsl_lpspi->base)) {
ret = PTR_ERR(fsl_lpspi->base); ret = PTR_ERR(fsl_lpspi->base);
goto out_controller_put; return ret;
} }
fsl_lpspi->base_phys = res->start; fsl_lpspi->base_phys = res->start;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
ret = irq; ret = irq;
goto out_controller_put; return ret;
} }
ret = devm_request_irq(&pdev->dev, irq, fsl_lpspi_isr, 0, ret = devm_request_irq(&pdev->dev, irq, fsl_lpspi_isr, 0,
dev_name(&pdev->dev), fsl_lpspi); dev_name(&pdev->dev), fsl_lpspi);
if (ret) { if (ret) {
dev_err(&pdev->dev, "can't get irq%d: %d\n", irq, ret); dev_err(&pdev->dev, "can't get irq%d: %d\n", irq, ret);
goto out_controller_put; return ret;
} }
fsl_lpspi->clk_per = devm_clk_get(&pdev->dev, "per"); fsl_lpspi->clk_per = devm_clk_get(&pdev->dev, "per");
if (IS_ERR(fsl_lpspi->clk_per)) { if (IS_ERR(fsl_lpspi->clk_per)) {
ret = PTR_ERR(fsl_lpspi->clk_per); ret = PTR_ERR(fsl_lpspi->clk_per);
goto out_controller_put; return ret;
} }
fsl_lpspi->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); fsl_lpspi->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
if (IS_ERR(fsl_lpspi->clk_ipg)) { if (IS_ERR(fsl_lpspi->clk_ipg)) {
ret = PTR_ERR(fsl_lpspi->clk_ipg); ret = PTR_ERR(fsl_lpspi->clk_ipg);
goto out_controller_put; return ret;
} }
/* enable the clock */ /* enable the clock */
ret = fsl_lpspi_init_rpm(fsl_lpspi); ret = fsl_lpspi_init_rpm(fsl_lpspi);
if (ret) if (ret)
goto out_controller_put; return ret;
ret = pm_runtime_get_sync(fsl_lpspi->dev); ret = pm_runtime_get_sync(fsl_lpspi->dev);
if (ret < 0) { if (ret < 0) {
...@@ -945,8 +945,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev) ...@@ -945,8 +945,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
pm_runtime_dont_use_autosuspend(fsl_lpspi->dev); pm_runtime_dont_use_autosuspend(fsl_lpspi->dev);
pm_runtime_put_sync(fsl_lpspi->dev); pm_runtime_put_sync(fsl_lpspi->dev);
pm_runtime_disable(fsl_lpspi->dev); pm_runtime_disable(fsl_lpspi->dev);
out_controller_put:
spi_controller_put(controller);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment