]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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 07:17:22 +0000 (09:17 +0200)
[ 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

index a483747cdc9b91def9f6315109b9bca6342232c2..b520de11fc17f7af414470f6173ced890dc3c109 100644 (file)
@@ -1315,7 +1315,7 @@ static int xadc_remove(struct platform_device *pdev)
        }
        free_irq(irq, indio_dev);
        clk_disable_unprepare(xadc->clk);
-       cancel_delayed_work(&xadc->zynq_unmask_work);
+       cancel_delayed_work_sync(&xadc->zynq_unmask_work);
        kfree(xadc->data);
        kfree(indio_dev->channels);