aboutsummaryrefslogtreecommitdiff
path: root/drivers/watchdog/watchdog_core.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-05-22 11:40:26 +0200
committerWim Van Sebroeck <wim@iguana.be>2012-05-30 07:55:23 +0200
commitf4e9c82f64b524314a390b13d3ba7d483f09258f (patch)
tree82d688ae7782234dc01c6a340596bac21531aae4 /drivers/watchdog/watchdog_core.c
parent7a87982420e5e126bfefeb42232d1fd92052794e (diff)
watchdog: Add Locking support
This patch fixes some potential multithreading issues, despite only allowing one process to open the /dev/watchdog device, we can still get called multiple times at the same time, since a program could be using thread, or could share the fd after a fork. This causes 2 potential problems: 1) watchdog_start / open do an unlocked test_n_set / test_n_clear, if these 2 race, the watchdog could be stopped while the active bit indicates it is running or visa versa. 2) Most watchdog_dev drivers probably assume that only one watchdog-op will get called at a time, this is not necessary true atm. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/watchdog_core.c')
-rw-r--r--drivers/watchdog/watchdog_core.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 86a57673abf..6aa46a90ff0 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -79,6 +79,7 @@ int watchdog_register_device(struct watchdog_device *wdd)
* corrupted in a later stage then we expect a kernel panic!
*/
+ mutex_init(&wdd->lock);
id = ida_simple_get(&watchdog_ida, 0, MAX_DOGS, GFP_KERNEL);
if (id < 0)
return id;