FAILED: patch "[PATCH] spi: pxa2xx: Fix use-after-free on unbind" failed to apply to 4.9-stable tree
[email protected]
maintainerThe patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 5626308bb94d9f930aa5f7c77327df4c6daa7759 Mon Sep 17 00:00:00 2001
From: Lukas Wunner <[email protected]>
Date: Mon, 7 Dec 2020 09:17:05 +0100
Subject: [PATCH] spi: pxa2xx: Fix use-after-free on unbind
pxa2xx_spi_remove() accesses the driver's private data after calling spi_unregister_controller() even though that function releases the last reference on the spi_controller and thereby frees the private data.
Fix by switching over to the new devm_spi_alloc_master/slave() helper which keeps the private data accessible until the driver has unbound.
drivers/spi/spi-pxa2xx.c +2 -3
@@ -1691,9 +1691,9 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) }if (platform_info->is_slave) - controller =spi_alloc_slave (dev,sizeof (struct driver_data )); + controller =devm_spi_alloc_slave (dev,sizeof (*drv_data));else - controller =spi_alloc_master (dev,sizeof (struct driver_data )); + controller =devm_spi_alloc_master (dev,sizeof (*drv_data));if (!controller) {dev_err (&pdev->dev,"cannot alloc spi_controller\n" );
@@ -1916,7 +1916,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)free_irq (ssp->irq, drv_data); out_error_controller_alloc: -spi_controller_put (controller);pxa_ssp_free (ssp);return status; }