Commit d6921700 authored by Tomas Winkler's avatar Tomas Winkler Committed by Wim Van Sebroeck

watchdog: mei: avoid oops in watchdog unregister code path

With commit c7d3df35 "mei: use internal watchdog device registration
tracking" will crash the kernel on shutdown path on systems
where ME watchdog is not present.
Since the watchdog was never initialized in such case
the WDOG_UNREGISTERED bit is never set and the system
crashes on access to uninitialized variables down the path.

To solve the issue we query for NULL on watchdog driver driver_data
to check whether the device is registered. This is handled in the
driver and doesn't depend on watchdog core internals.

Cc: Borislav Petkov <bp@alien8.de>
Cc: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: default avatarJerry Snitselaar <jerry.snitselaar@oracle.com>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 8c4c419c
...@@ -370,7 +370,7 @@ void mei_watchdog_register(struct mei_device *dev) ...@@ -370,7 +370,7 @@ void mei_watchdog_register(struct mei_device *dev)
void mei_watchdog_unregister(struct mei_device *dev) void mei_watchdog_unregister(struct mei_device *dev)
{ {
if (test_bit(WDOG_UNREGISTERED, &amt_wd_dev.status)) if (watchdog_get_drvdata(&amt_wd_dev) == NULL)
return; return;
watchdog_set_drvdata(&amt_wd_dev, NULL); watchdog_set_drvdata(&amt_wd_dev, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment