linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [char-misc for 3.8] mei: avoid oops in watchdog unregister code path
@ 2012-12-16 11:23 Tomas Winkler
  2012-12-17  2:39 ` Wanlong Gao
  0 siblings, 1 reply; 2+ messages in thread
From: Tomas Winkler @ 2012-12-16 11:23 UTC (permalink / raw)
  To: gregkh, hdegoede, wim
  Cc: arnd, alan, linux-kernel, linux-watchdog, Tomas Winkler,
	Borislav Petkov, Wanlong Gao, Jerry Snitselaar

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.

Cc: Borislav Petkov <bp@alien8.de>
Cc: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/misc/mei/wd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 636409f..9299a8c 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -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);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [char-misc for 3.8] mei: avoid oops in watchdog unregister code path
  2012-12-16 11:23 [char-misc for 3.8] mei: avoid oops in watchdog unregister code path Tomas Winkler
@ 2012-12-17  2:39 ` Wanlong Gao
  0 siblings, 0 replies; 2+ messages in thread
From: Wanlong Gao @ 2012-12-17  2:39 UTC (permalink / raw)
  To: Tomas Winkler
  Cc: gregkh, hdegoede, wim, arnd, alan, linux-kernel, linux-watchdog,
	Borislav Petkov, Jerry Snitselaar

On 12/16/2012 07:23 PM, Tomas Winkler wrote:
> 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.
> 
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> Signed-off-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>

Fixed the panic here, thank you.

Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

> ---
>  drivers/misc/mei/wd.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
> index 636409f..9299a8c 100644
> --- a/drivers/misc/mei/wd.c
> +++ b/drivers/misc/mei/wd.c
> @@ -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);
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-17  2:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-16 11:23 [char-misc for 3.8] mei: avoid oops in watchdog unregister code path Tomas Winkler
2012-12-17  2:39 ` Wanlong Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).