sata_dwc_460ex: fix resource leak on error path
[pandora-kernel.git] / drivers / watchdog / watchdog_dev.c
index faf4e18..6aaefba 100644 (file)
@@ -469,8 +469,10 @@ static int watchdog_release(struct inode *inode, struct file *file)
         * or if WDIOF_MAGICCLOSE is not set. If nowayout was set then
         * watchdog_stop will fail.
         */
-       if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) ||
-           !(wdd->info->options & WDIOF_MAGICCLOSE))
+       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))
                err = watchdog_stop(wdd);
 
        /* If the watchdog was not stopped, send a keepalive ping */