mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
spi: pxa2xx: Fix use-after-free on unbind
commit5626308bb9
upstream 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. Fixes:32e5b57232
("spi: pxa2xx: Fix controller unregister order") Signed-off-by: Lukas Wunner <lukas@wunner.de> Cc: <stable@vger.kernel.org> # v2.6.17+:5e844cc37a
: spi: Introduce device-managed SPI controller allocation Cc: <stable@vger.kernel.org> # v2.6.17+:32e5b57232
: spi: pxa2xx: Fix controller unregister order Cc: <stable@vger.kernel.org> # v2.6.17+ Link: https://lore.kernel.org/r/5764b04d4a6e43069ebb7808f64c2f774ac6f193.1607286887.git.lukas@wunner.de Signed-off-by: Mark Brown <broonie@kernel.org> [sudip: adjust context] Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f30c728d5b
commit
d34e2cba77
1 changed files with 1 additions and 2 deletions
|
@ -1572,7 +1572,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
master = spi_alloc_master(dev, sizeof(struct driver_data));
|
||||
master = devm_spi_alloc_master(dev, sizeof(*drv_data));
|
||||
if (!master) {
|
||||
dev_err(&pdev->dev, "cannot alloc spi_master\n");
|
||||
pxa_ssp_free(ssp);
|
||||
|
@ -1759,7 +1759,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
|
|||
free_irq(ssp->irq, drv_data);
|
||||
|
||||
out_error_master_alloc:
|
||||
spi_controller_put(master);
|
||||
pxa_ssp_free(ssp);
|
||||
return status;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue