spi: bcm2835aux: Fix use-after-free on unbind
authorLukas Wunner <lukas@wunner.de>
Wed, 11 Nov 2020 19:07:30 +0000 (20:07 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 12 Nov 2020 15:05:36 +0000 (15:05 +0000)
commite13ee6cc4781edaf8c7321bee19217e3702ed481
tree57ca94ecb960c6e0b57a51d845ce91bcf8ccc8e5
parente1483ac030fb4c57734289742f1c1d38dca61e22
spi: bcm2835aux: Fix use-after-free on unbind

bcm2835aux_spi_remove() accesses the driver's private data after calling
spi_unregister_master() even though that function releases the last
reference on the spi_master 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: b9dd3f6d4172 ("spi: bcm2835aux: Fix controller unregister order")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: <stable@vger.kernel.org> # v4.4+: 123456789abc: spi: Introduce device-managed SPI controller allocation
Cc: <stable@vger.kernel.org> # v4.4+: b9dd3f6d4172: spi: bcm2835aux: Fix controller unregister order
Cc: <stable@vger.kernel.org> # v4.4+
Link: https://lore.kernel.org/r/b290b06357d0c0bdee9cecc539b840a90630f101.1605121038.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-bcm2835aux.c