]> git.baikalelectronics.ru Git - kernel.git/commit
spi: bcm2835: Fix use-after-free on unbind
authorLukas Wunner <lukas@wunner.de>
Wed, 11 Nov 2020 19:07:20 +0000 (20:07 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 12 Nov 2020 15:05:35 +0000 (15:05 +0000)
commit44aa588507b0031c6989e3ea44ca6b9d15641854
tree63c3622713b691047e276380889c671943d56203
parent8add58bf4e1be734fc2701c9a7bd432392e414b2
spi: bcm2835: Fix use-after-free on unbind

bcm2835_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() helper which
keeps the private data accessible until the driver has unbound.

Fixes: ac1827c6b683 ("spi: add driver for BCM2835")
Reported-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: <stable@vger.kernel.org> # v3.10+: 123456789abc: spi: Introduce device-managed SPI controller allocation
Cc: <stable@vger.kernel.org> # v3.10+
Cc: Vladimir Oltean <olteanv@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/ad66e0a0ad96feb848814842ecf5b6a4539ef35c.1605121038.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-bcm2835.c