Skip to content

Commit bff892a

Browse files
NXP-CarlosSongbroonie
authored andcommitted
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: 2ae0ab0 ("spi: lpspi: Avoid potential use-after-free in probe()") Signed-off-by: Carlos Song <[email protected]> Reviewed-by: Alexander Sverdlin <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a3d3eab commit bff892a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/spi/spi-fsl-lpspi.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -852,39 +852,39 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
852852
fsl_lpspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
853853
if (IS_ERR(fsl_lpspi->base)) {
854854
ret = PTR_ERR(fsl_lpspi->base);
855-
goto out_controller_put;
855+
return ret;
856856
}
857857
fsl_lpspi->base_phys = res->start;
858858

859859
irq = platform_get_irq(pdev, 0);
860860
if (irq < 0) {
861861
ret = irq;
862-
goto out_controller_put;
862+
return ret;
863863
}
864864

865865
ret = devm_request_irq(&pdev->dev, irq, fsl_lpspi_isr, 0,
866866
dev_name(&pdev->dev), fsl_lpspi);
867867
if (ret) {
868868
dev_err(&pdev->dev, "can't get irq%d: %d\n", irq, ret);
869-
goto out_controller_put;
869+
return ret;
870870
}
871871

872872
fsl_lpspi->clk_per = devm_clk_get(&pdev->dev, "per");
873873
if (IS_ERR(fsl_lpspi->clk_per)) {
874874
ret = PTR_ERR(fsl_lpspi->clk_per);
875-
goto out_controller_put;
875+
return ret;
876876
}
877877

878878
fsl_lpspi->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
879879
if (IS_ERR(fsl_lpspi->clk_ipg)) {
880880
ret = PTR_ERR(fsl_lpspi->clk_ipg);
881-
goto out_controller_put;
881+
return ret;
882882
}
883883

884884
/* enable the clock */
885885
ret = fsl_lpspi_init_rpm(fsl_lpspi);
886886
if (ret)
887-
goto out_controller_put;
887+
return ret;
888888

889889
ret = pm_runtime_get_sync(fsl_lpspi->dev);
890890
if (ret < 0) {
@@ -945,8 +945,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
945945
pm_runtime_dont_use_autosuspend(fsl_lpspi->dev);
946946
pm_runtime_put_sync(fsl_lpspi->dev);
947947
pm_runtime_disable(fsl_lpspi->dev);
948-
out_controller_put:
949-
spi_controller_put(controller);
950948

951949
return ret;
952950
}

0 commit comments

Comments
 (0)