This is a note to let you know that I've just added the patch titled spi: lpspi: Fix use-after-free on unbind to the 5.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: spi-lpspi-fix-use-after-free-on-unbind.patch and it can be found in the queue-5.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 4def49da620c84a682d9361d6bef0a97eed46fe0 Mon Sep 17 00:00:00 2001 From: Lukas Wunner <lukas@xxxxxxxxx> Date: Sun, 8 Nov 2020 23:41:00 +0100 Subject: spi: lpspi: Fix use-after-free on unbind From: Lukas Wunner <lukas@xxxxxxxxx> commit 4def49da620c84a682d9361d6bef0a97eed46fe0 upstream. 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: 944c01a889d9 ("spi: lpspi: enable runtime pm for lpspi") Signed-off-by: Lukas Wunner <lukas@xxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> # v5.2+ Cc: Han Xu <han.xu@xxxxxxx> Link: https://lore.kernel.org/r/ab3c0b18bd820501a12c85e440006e09ec0e275f.1604874488.git.lukas@xxxxxxxxx Signed-off-by: Mark Brown <broonie@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/spi/spi-fsl-lpspi.c | 3 --- 1 file changed, 3 deletions(-) --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -938,9 +938,6 @@ static int fsl_lpspi_remove(struct platf spi_controller_get_devdata(controller); pm_runtime_disable(fsl_lpspi->dev); - - spi_master_put(controller); - return 0; } Patches currently in stable-queue which might be from lukas@xxxxxxxxx are queue-5.9/spi-bcm2835aux-fix-use-after-free-on-unbind.patch queue-5.9/spi-lpspi-fix-use-after-free-on-unbind.patch queue-5.9/spi-npcm-fiu-don-t-leak-spi-master-in-probe-error-path.patch queue-5.9/spi-introduce-device-managed-spi-controller-allocation.patch