Skip to content

Commit 4def49d

Browse files
l1kbroonie
authored andcommitted
spi: lpspi: Fix use-after-free on unbind
Normally the last reference on an spi_controller is released by spi_unregister_controller(). In the case of the i.MX lpspi driver, the spi_controller is registered with devm_spi_register_controller(), so spi_unregister_controller() is invoked automatically after the driver has unbound. However the driver already releases the last reference in fsl_lpspi_remove() through a gratuitous call to spi_master_put(), causing a use-after-free when spi_unregister_controller() is subsequently invoked by the devres framework. Fix by dropping the superfluous spi_master_put(). Fixes: 944c01a ("spi: lpspi: enable runtime pm for lpspi") Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: <stable@vger.kernel.org> # v5.2+ Cc: Han Xu <han.xu@nxp.com> Link: https://lore.kernel.org/r/ab3c0b18bd820501a12c85e440006e09ec0e275f.1604874488.git.lukas@wunner.de Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent ee4ad5d commit 4def49d

1 file changed

Lines changed: 0 additions & 3 deletions

File tree

drivers/spi/spi-fsl-lpspi.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,6 @@ static int fsl_lpspi_remove(struct platform_device *pdev)
938938
spi_controller_get_devdata(controller);
939939

940940
pm_runtime_disable(fsl_lpspi->dev);
941-
942-
spi_master_put(controller);
943-
944941
return 0;
945942
}
946943

0 commit comments

Comments
 (0)