Skip to contentSkip to conversation

Watchdog: Fixed the watchdog close/stop logic - only close the watchdog if the magic character was received and the magic close is supported.

PATCH In review Robert Yang 3 participants 3 messages Dec 8, 2014 – Dec 9, 2014 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Watchdog: Fixed the watchdog close/stop logic - only close the watchdog if the magic character was received and the magic close is supported.

From: ryang <[email protected]>

---
 drivers/watchdog/watchdog_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/watchdog_dev.c +2 -2
index 6aaefba..73793d8 100644
@@ -471,8 +471,8 @@ static int watchdog_release(struct inode *inode, struct file *file)
 	 */
 	if (!test_bit(WDOG_ACTIVE, &wdd->status))
 		err = 0;
-	else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) ||
-		 !(wdd->info->options & WDIOF_MAGICCLOSE))
+	else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) &&
+		(wdd->info->options & WDIOF_MAGICCLOSE))
 		err = watchdog_stop(wdd);
 
 	/* If the watchdog was not stopped, send a keepalive ping */
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 12 lines · Robert Yang

From: ryang <[email protected]>

---
 drivers/watchdog/watchdog_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/watchdog_dev.c +0 -0
index 6aaefba..73793d8 100644

drivers/watchdog/watchdog_dev.c static int watchdog_release(struct inode *inode, struct file *file) · line 477

Quoted 9 lines
drivers/watchdog/watchdog_dev.c +2 -2
@@ -471,8 +471,8 @@ static int watchdog_release(struct inode *inode, struct file *file)
 	 */
 	if (!test_bit(WDOG_ACTIVE, &wdd->status))
 		err = 0;
-	else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) ||
-		 !(wdd->info->options & WDIOF_MAGICCLOSE))
+	else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) &&
+		(wdd->info->options & WDIOF_MAGICCLOSE))
 		err = watchdog_stop(wdd);
 

Why ?

Guenter

#2 lore raw
In reply to Robert Yang

Hi Ryang,

Quoted 13 lines

From: ryang <[email protected]>

---
 drivers/watchdog/watchdog_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/watchdog_dev.c +0 -0
index 6aaefba..73793d8 100644

drivers/watchdog/watchdog_dev.c static int watchdog_release(struct inode *inode, struct file *file) · line 478

Quoted 10 lines
drivers/watchdog/watchdog_dev.c +2 -2
@@ -471,8 +471,8 @@ static int watchdog_release(struct inode *inode, struct file *file)
 	 */
 	if (!test_bit(WDOG_ACTIVE, &wdd->status))
 		err = 0;
-	else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) ||
-		 !(wdd->info->options & WDIOF_MAGICCLOSE))
+	else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) &&
+		(wdd->info->options & WDIOF_MAGICCLOSE))
 		err = watchdog_stop(wdd);
 
 	/* If the watchdog was not stopped, send a keepalive ping */

There is no reason for this change; you either have:
1) WDIOF_MAGICCLOSE is not supported and thus watchog may be stopped.
2) If a watchdog daemon crashes and thus closes the watchdog device (and thus it did not sent a Magic Char) then the watchdog should not be stopped but needs to reboot the system.

Kind regards,
Wim.