spi: fix use-after-free at controller deregistration
authorJohan Hovold <johan@kernel.org>
Mon, 30 Oct 2017 10:35:25 +0000 (11:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Nov 2017 08:49:24 +0000 (09:49 +0100)
commit9aacd82304adb74fa9320cb1c5d4bc71b1b91f06
tree3d1de9fbcef4ef03d4a3fb63e9a624e04053c1ba
parentd3e36fd07b5b27768db8353a83dec0459bf2ee33
spi: fix use-after-free at controller deregistration

commit 67f7b2781fafcc0f52464880154b320fea1ae982 upstream.

The controller is typically freed as part of device_unregister() so
store the bus id before deregistration to avoid use-after-free when the
id is later released.

Fixes: 9b61e302210e ("spi: Pick spi bus number from Linux idr or spi alias")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spi/spi.c