Message ID | 20190819203711.32599-2-minyard@acm.org (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | [01/12] watchdog: NULL the default governor if it is unregistered | expand |
On Mon, Aug 19, 2019 at 03:37:00PM -0500, minyard@acm.org wrote: > From: Corey Minyard <cminyard@mvista.com> > > Otherwise it could be used after being freed. > > Signed-off-by: Corey Minyard <cminyard@mvista.com> > --- > drivers/watchdog/watchdog_pretimeout.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/watchdog/watchdog_pretimeout.c b/drivers/watchdog/watchdog_pretimeout.c > index 01ca84be240f..b45041b0ef39 100644 > --- a/drivers/watchdog/watchdog_pretimeout.c > +++ b/drivers/watchdog/watchdog_pretimeout.c > @@ -162,6 +162,8 @@ void watchdog_unregister_governor(struct watchdog_governor *gov) > break; > } > } > + if (gov == default_gov) > + default_gov = NULL; > Good catch. I think this should be inside the spinlock. I do wonder though why it was removed with commit da0d12ff2b82 ("watchdog: pretimeout: add panic pretimeout governor"). I think it was wrong to remove it, but I may be missing something. Vladimir, do you recall ? Guenter > spin_lock_irq(&pretimeout_lock); > list_for_each_entry(p, &pretimeout_list, entry) > -- > 2.17.1 >
diff --git a/drivers/watchdog/watchdog_pretimeout.c b/drivers/watchdog/watchdog_pretimeout.c index 01ca84be240f..b45041b0ef39 100644 --- a/drivers/watchdog/watchdog_pretimeout.c +++ b/drivers/watchdog/watchdog_pretimeout.c @@ -162,6 +162,8 @@ void watchdog_unregister_governor(struct watchdog_governor *gov) break; } } + if (gov == default_gov) + default_gov = NULL; spin_lock_irq(&pretimeout_lock); list_for_each_entry(p, &pretimeout_list, entry)