]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
spi: rpc-if: Fix use-after-free on unbind
authorLukas Wunner <lukas@wunner.de>
Mon, 7 Dec 2020 08:17:06 +0000 (09:17 +0100)
committerPaolo Pisati <paolo.pisati@canonical.com>
Mon, 4 Jan 2021 15:48:01 +0000 (16:48 +0100)
commit4bee3bddd62608e761275754f6dec9d371b3d52c
tree33457634a7f6add21ba01bb078ef87e1bb56bb29
parentf845ce6e456449dc7916ab99bd19782dd3c67842
spi: rpc-if: Fix use-after-free on unbind

BugLink: https://bugs.launchpad.net/bugs/1910111
commit 393f981ca5f797b58b882d42b7621fb6e43c7f5b upstream.

rpcif_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: eb8d6d464a27 ("spi: add Renesas RPC-IF driver")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: <stable@vger.kernel.org> # v5.9+: 5e844cc37a5c: spi: Introduce device-managed SPI controller allocation
Cc: <stable@vger.kernel.org> # v5.9+
Cc: Sergei Shtylyov <s.shtylyov@omprussia.ru>
Link: https://lore.kernel.org/r/c5da472c28021da2f6517441685cef033d40b140.1607286887.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/spi/spi-rpc-if.c