spi: davinci: Fix use-after-free on unbind
commit065424db6292c09c7ee67d20af83580b7f762809
authorLukas Wunner <lukas@wunner.de>
Mon, 7 Dec 2020 08:17:01 +0000 (7 09:17 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Dec 2020 12:45:06 +0000 (29 13:45 +0100)
tree63eb388cbc713f606a2ee7cea4dc4fa9dc7f537e
parent10af52bf856f2d92ae96cd87755ee72103414e09
spi: davinci: Fix use-after-free on unbind

commit 373afef350a93519b4b8d636b0895da8650b714b upstream.

davinci_spi_remove() accesses the driver's private data after it's been
freed with spi_master_put().

Fix by moving the spi_master_put() to the end of the function.

Fixes: fe5fd2540947 ("spi: davinci: Use dma_request_chan() for requesting DMA channel")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: <stable@vger.kernel.org> # v4.7+
Link: https://lore.kernel.org/r/412f7eb1cf8990e0a3a2153f4c577298deab623e.1607286887.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spi/spi-davinci.c