mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
watchdog: core: fix null pointer dereference when releasing cdev
[ Upstream commit953b9dd772] watchdog_stop() calls watchdog_update_worker() which needs a valid wdd->wd_data pointer. So, when unregistering the cdev, clear the pointers after we call watchdog_stop(), not before. Fixes:bb292ac1c6("watchdog: Introduce watchdog_stop_on_unregister helper") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a9f36455ed
commit
f4cfb7eeae
@@ -1019,16 +1019,16 @@ static void watchdog_cdev_unregister(struct watchdog_device *wdd)
|
||||
old_wd_data = NULL;
|
||||
}
|
||||
|
||||
mutex_lock(&wd_data->lock);
|
||||
wd_data->wdd = NULL;
|
||||
wdd->wd_data = NULL;
|
||||
mutex_unlock(&wd_data->lock);
|
||||
|
||||
if (watchdog_active(wdd) &&
|
||||
test_bit(WDOG_STOP_ON_UNREGISTER, &wdd->status)) {
|
||||
watchdog_stop(wdd);
|
||||
}
|
||||
|
||||
mutex_lock(&wd_data->lock);
|
||||
wd_data->wdd = NULL;
|
||||
wdd->wd_data = NULL;
|
||||
mutex_unlock(&wd_data->lock);
|
||||
|
||||
hrtimer_cancel(&wd_data->timer);
|
||||
kthread_cancel_work_sync(&wd_data->work);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user