iio: adc: xilinx: fix potential use-after-free on remove
authorSven Van Asbroeck <thesven73@gmail.com>
Sun, 10 Mar 2019 18:58:24 +0000 (14:58 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 May 2019 17:43:40 +0000 (19:43 +0200)
commitd1a8691fff95cdb100739281854b0afafb8c57df
tree6ae8423cee2207b25e0755486137008247f0356e
parent2651afdcada7189529becd2d62be0f4b6bdfd2ab
iio: adc: xilinx: fix potential use-after-free on remove

[ Upstream commit 62039b6aef63380ba7a37c113bbaeee8a55c5342 ]

When cancel_delayed_work() returns, the delayed work may still
be running. This means that the core could potentially free
the private structure (struct xadc) while the delayed work
is still using it. This is a potential use-after-free.

Fix by calling cancel_delayed_work_sync(), which waits for
any residual work to finish before returning.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/adc/xilinx-xadc-core.c