Skip to contentSkip to conversation

mei: avoid oops in watchdog unregister code path

char-misc for 3.8 Tomas Winkler 2 participants 2 messages Dec 16, 2012 – Dec 17, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

With commit c7d3df3 "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.

---
 drivers/misc/mei/wd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/misc/mei/wd.c +1 -1
index 636409f..9299a8c 100644
@@ -370,7 +370,7 @@ void mei_watchdog_register(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;
 
 	watchdog_set_drvdata(&amt_wd_dev, NULL);
Signature · 1 line
1.7.4.4
Tested-by
#1 lore raw
Quoted 7 lines · Tomas Winkler

With commit c7d3df3 "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.

Quoted 8 lines

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.

Fixed the panic here, thank you.

Quoted 18 lines
---
 drivers/misc/mei/wd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/misc/mei/wd.c +1 -1
index 636409f..9299a8c 100644
@@ -370,7 +370,7 @@ void mei_watchdog_register(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;
 
 	watchdog_set_drvdata(&amt_wd_dev, NULL);