watchdog: Only disable/enable watchdog if neccessary
authorMandeep Singh Baines <msb@chromium.org>
Mon, 23 May 2011 05:10:21 +0000 (22:10 -0700)
committerIngo Molnar <mingo@elte.hu>
Mon, 23 May 2011 09:58:58 +0000 (11:58 +0200)
Don't take any action on an unsuccessful write to /proc.

Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Cc: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1306127423-3347-2-git-send-email-msb@chromium.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/watchdog.c

index a06972d..cf0e09f 100644 (file)
@@ -507,15 +507,19 @@ static void watchdog_disable_all_cpus(void)
 int proc_dowatchdog_enabled(struct ctl_table *table, int write,
                     void __user *buffer, size_t *length, loff_t *ppos)
 {
-       proc_dointvec(table, write, buffer, length, ppos);
+       int ret;
 
-       if (write) {
-               if (watchdog_enabled)
-                       watchdog_enable_all_cpus();
-               else
-                       watchdog_disable_all_cpus();
-       }
-       return 0;
+       ret = proc_dointvec(table, write, buffer, length, ppos);
+       if (ret || !write)
+               goto out;
+
+       if (watchdog_enabled)
+               watchdog_enable_all_cpus();
+       else
+               watchdog_disable_all_cpus();
+
+out:
+       return ret;
 }
 
 int proc_dowatchdog_thresh(struct ctl_table *table, int write,