Commit 359e6fab authored by Michal Hocko's avatar Michal Hocko Committed by Linus Torvalds

watchdog: update watchdog attributes atomically

proc_dowatchdog doesn't synchronize multiple callers which might lead to
confusion when two parallel callers might confuse watchdog_enable_all_cpus
resp watchdog_disable_all_cpus (eg watchdog gets enabled even if
watchdog_thresh was set to 0 already).

This patch adds a local mutex which synchronizes callers to the sysctl
Signed-off-by: default avatarMichal Hocko <>
Cc: Frederic Weisbecker <>
Acked-by: default avatarDon Zickus <>
Cc: Thomas Gleixner <>
Cc: Ingo Molnar <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 4a10c2ac
......@@ -520,13 +520,15 @@ int proc_dowatchdog(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
int err, old_thresh, old_enabled;
static DEFINE_MUTEX(watchdog_proc_mutex);
old_thresh = ACCESS_ONCE(watchdog_thresh);
old_enabled = ACCESS_ONCE(watchdog_user_enabled);
err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (err || !write)
return err;
goto out;
......@@ -544,7 +546,8 @@ int proc_dowatchdog(struct ctl_table *table, int write,
watchdog_thresh = old_thresh;
watchdog_user_enabled = old_enabled;
return err;
#endif /* CONFIG_SYSCTL */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment