]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
spi: spi-sh: Fix use-after-free on unbind
authorLukas Wunner <lukas@wunner.de>
Mon, 7 Dec 2020 08:17:04 +0000 (09:17 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 7 Dec 2020 14:18:50 +0000 (14:18 +0000)
commite77df3eca12be4b17f13cf9f215cff248c57d98f
tree2b9ba6b08b4e7ceb08e523bf02f0d92cf645d4e0
parent6cfd39e212dee2e77a0227ce4e0f55fa06d79f46
spi: spi-sh: Fix use-after-free on unbind

spi_sh_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: 680c1305e259 ("spi/spi_sh: use spi_unregister_master instead of spi_master_put in remove path")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: <stable@vger.kernel.org> # v3.0+: 5e844cc37a5c: spi: Introduce device-managed SPI controller allocation
Cc: <stable@vger.kernel.org> # v3.0+
Cc: Axel Lin <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/6d97628b536baf01d5e3e39db61108f84d44c8b2.1607286887.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-sh.c