mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH REVIEW 1/2] watchdog: extend the mutex-protected section in watchdog_cdev_unregister()
@ 2022-08-18  2:06 Alexey Klimov
  2022-08-18  2:06 ` [PATCH REVIEW 2/2] watchdog: add wd_data->lock mutex locking to watchdog_open() Alexey Klimov
  2022-08-18 16:55 ` [PATCH REVIEW 1/2] watchdog: extend the mutex-protected section in watchdog_cdev_unregister() Guenter Roeck
  0 siblings, 2 replies; 5+ messages in thread
From: Alexey Klimov @ 2022-08-18  2:06 UTC (permalink / raw)
  To: linux-watchdog; +Cc: wim, linux, linux-kernel, klimov.linux

watchdog_stop() should be called with wd_data->lock mutex locked.
Updates to wdd->status also occur under this look throughout the
watchdog_dev.c as well as functions that deal with pretimeout hrtimer
like watchdog_hrtimer_pretimeout_stop() here.

Signed-off-by: Alexey Klimov <aklimov@redhat.com>
---
 drivers/watchdog/watchdog_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 54903f3c851e..804236a094f6 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -1095,6 +1095,8 @@ static void watchdog_cdev_unregister(struct watchdog_device *wdd)
 		old_wd_data = NULL;
 	}
 
+	mutex_lock(&wd_data->lock);
+
 	if (watchdog_active(wdd) &&
 	    test_bit(WDOG_STOP_ON_UNREGISTER, &wdd->status)) {
 		watchdog_stop(wdd);
@@ -1102,7 +1104,6 @@ static void watchdog_cdev_unregister(struct watchdog_device *wdd)
 
 	watchdog_hrtimer_pretimeout_stop(wdd);
 
-	mutex_lock(&wd_data->lock);
 	wd_data->wdd = NULL;
 	wdd->wd_data = NULL;
 	mutex_unlock(&wd_data->lock);
-- 
2.37.2


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

end of thread, other threads:[~2022-08-18 16:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18  2:06 [PATCH REVIEW 1/2] watchdog: extend the mutex-protected section in watchdog_cdev_unregister() Alexey Klimov
2022-08-18  2:06 ` [PATCH REVIEW 2/2] watchdog: add wd_data->lock mutex locking to watchdog_open() Alexey Klimov
2022-08-18  9:09   ` Christophe Leroy
2022-08-18 16:57   ` Guenter Roeck
2022-08-18 16:55 ` [PATCH REVIEW 1/2] watchdog: extend the mutex-protected section in watchdog_cdev_unregister() Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®