Skip to contentSkip to conversation

watchdog/xen: don't clear is_active when xen_wdt_stop() failed

PATCH In review Jan Beulich 3 participants 4 messages Mar 19, 2012 – Mar 22, 2012 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog/xen: don't clear is_active when xen_wdt_stop() failed

xen_wdt_release() shouldn't clear is_active even when the watchdog didn't get stopped (which by itself shouldn't happen, but let's return a proper error in this case rather than adding a BUG() upon hypercall failure).

---
 drivers/watchdog/xen_wdt.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/watchdog/xen_wdt.c +5 -3
@@ -131,16 +131,18 @@ static int xen_wdt_open(struct inode *in
 
 static int xen_wdt_release(struct inode *inode, struct file *file)
 {
+	int err = 0;
+
 	if (expect_release)
-		xen_wdt_stop();
+		err = xen_wdt_stop();
 	else {
 		printk(KERN_CRIT PFX
 		       "unexpected close, not stopping watchdog!\n");
 		xen_wdt_kick();
 	}
-	is_active = false;
+	is_active = err;
 	expect_release = false;
-	return 0;
+	return err;
 }
 
 static ssize_t xen_wdt_write(struct file *file, const char __user *data,
#1 lore raw
Quoted 6 lines · Jan Beulich

xen_wdt_release() shouldn't clear is_active even when the watchdog didn't get stopped (which by itself shouldn't happen, but let's return a proper error in this case rather than adding a BUG() upon hypercall failure).

Looks good to me too. Wim, want me to carry it for 3.4?

Quoted 31 lines
---
 drivers/watchdog/xen_wdt.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/watchdog/xen_wdt.c +5 -3
@@ -131,16 +131,18 @@ static int xen_wdt_open(struct inode *in
 
 static int xen_wdt_release(struct inode *inode, struct file *file)
 {
+	int err = 0;
+
 	if (expect_release)
-		xen_wdt_stop();
+		err = xen_wdt_stop();
 	else {
 		printk(KERN_CRIT PFX
 		       "unexpected close, not stopping watchdog!\n");
 		xen_wdt_kick();
 	}
-	is_active = false;
+	is_active = err;
 	expect_release = false;
-	return 0;
+	return err;
 }
 
 static ssize_t xen_wdt_write(struct file *file, const char __user *data,
#2 lore raw
In reply to Jan Beulich

Hi Jan,

Quoted 25 lines

xen_wdt_release() shouldn't clear is_active even when the watchdog didn't get stopped (which by itself shouldn't happen, but let's return a proper error in this case rather than adding a BUG() upon hypercall failure).

---
 drivers/watchdog/xen_wdt.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/watchdog/xen_wdt.c +3 -1
@@ -131,16 +131,18 @@ static int xen_wdt_open(struct inode *in
 
 static int xen_wdt_release(struct inode *inode, struct file *file)
 {
+	int err = 0;
+
 	if (expect_release)
-		xen_wdt_stop();
+		err = xen_wdt_stop();
 	else {
 		printk(KERN_CRIT PFX
 		       "unexpected close, not stopping watchdog!\n");

drivers/watchdog/xen_wdt.c static int xen_wdt_open(struct inode *in · line 148

Quoted 10 lines
drivers/watchdog/xen_wdt.c +2 -2
 		xen_wdt_kick();
 	}
-	is_active = false;
+	is_active = err;
 	expect_release = false;
-	return 0;
+	return err;
 }
 
 static ssize_t xen_wdt_write(struct file *file, const char __user *data,

Just for my understanding:
is_active is a bool value and err is an integer. What values are returned by xen_wdt_stop?

Kind regards,
Wim.

#3 lore raw
Quoted 37 lines
Quoted 1 line
Quoted 1 line · Wim Van Sebroeck

Hi Jan,

Quoted 34 lines

xen_wdt_release() shouldn't clear is_active even when the watchdog didn't get stopped (which by itself shouldn't happen, but let's return a proper error in this case rather than adding a BUG() upon hypercall failure).

---
 drivers/watchdog/xen_wdt.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/watchdog/xen_wdt.c +5 -3
@@ -131,16 +131,18 @@ static int xen_wdt_open(struct inode *in
 
 static int xen_wdt_release(struct inode *inode, struct file *file)
 {
+	int err = 0;
+
 	if (expect_release)
-		xen_wdt_stop();
+		err = xen_wdt_stop();
 	else {
 		printk(KERN_CRIT PFX
 		       "unexpected close, not stopping watchdog!\n");
 		xen_wdt_kick();
 	}
-	is_active = false;
+	is_active = err;
 	expect_release = false;
-	return 0;
+	return err;
 }
 
Quoted 5 lines

drivers/watchdog/xen_wdt.c static int xen_wdt_open(struct inode *in · line 148

Quoted 1 line
drivers/watchdog/xen_wdt.c +0 -0
 static ssize_t xen_wdt_write(struct file *file, const char __user *data,

Just for my understanding:
is_active is a bool value and err is an integer. What values are returned by xen_wdt_stop?

xen_wdt_stop() returns the usual -errno values. Assignments from non-bool to bool convert the value (non-zero -> true, zero -> false), i.e. is_active gets set to false only if xen_wdt_stop() succeeded.

Jan