diff options
author | Sven Van Asbroeck <thesven73@gmail.com> | 2019-04-26 14:36:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-31 06:46:13 -0700 |
commit | 7fd0d9d10e5dcc9e84ed34474053d78ed33be517 (patch) | |
tree | 29f9b617d92a32a45bd210c1bd9556373431c280 | |
parent | 0ea8b7cf9436b526c833f2677c5caed04af6b9d4 (diff) | |
download | linux-stable-7fd0d9d10e5dcc9e84ed34474053d78ed33be517.tar.gz linux-stable-7fd0d9d10e5dcc9e84ed34474053d78ed33be517.tar.bz2 linux-stable-7fd0d9d10e5dcc9e84ed34474053d78ed33be517.zip |
rtc: 88pm860x: prevent use-after-free on device remove
[ Upstream commit f22b1ba15ee5785aa028384ebf77dd39e8e47b70 ]
The device's remove() attempts to shut down the delayed_work scheduled
on the kernel-global workqueue by calling flush_scheduled_work().
Unfortunately, flush_scheduled_work() does not prevent the delayed_work
from re-scheduling itself. The delayed_work might run after the device
has been removed, and touch the already de-allocated info structure.
This is a potential use-after-free.
Fix by calling cancel_delayed_work_sync() during remove(): this ensures
that the delayed work is properly cancelled, is no longer running, and
is not able to re-schedule itself.
This issue was detected with the help of Coccinelle.
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/rtc/rtc-88pm860x.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c index 01ffc0ef8033..fbcf13bbbd8d 100644 --- a/drivers/rtc/rtc-88pm860x.c +++ b/drivers/rtc/rtc-88pm860x.c @@ -414,7 +414,7 @@ static int pm860x_rtc_remove(struct platform_device *pdev) struct pm860x_rtc_info *info = platform_get_drvdata(pdev); #ifdef VRTC_CALIBRATION - flush_scheduled_work(); + cancel_delayed_work_sync(&info->calib_work); /* disable measurement */ pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0); #endif /* VRTC_CALIBRATION */ |