watchdog: core: Fix error handling of watchdog_dev_init()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Tue, 19 Jul 2016 11:22:34 +0000 (11:22 +0000)
committerWim Van Sebroeck <wim@iguana.be>
Mon, 25 Jul 2016 10:02:55 +0000 (12:02 +0200)
Fix the error handling paths of watchdog_dev_init().

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/watchdog_dev.c

index 270f4bf291e3dfe95817a93f996cb3643ce90aac..f128efc361352a9e19b80c6eb580e7e61565c2ba 100644 (file)
@@ -972,17 +972,22 @@ int __init watchdog_dev_init(void)
        err = class_register(&watchdog_class);
        if (err < 0) {
                pr_err("couldn't register class\n");
-               return err;
+               goto err_register;
        }
 
        err = alloc_chrdev_region(&watchdog_devt, 0, MAX_DOGS, "watchdog");
        if (err < 0) {
                pr_err("watchdog: unable to allocate char dev region\n");
-               class_unregister(&watchdog_class);
-               return err;
+               goto err_alloc;
        }
 
        return 0;
+
+err_alloc:
+       class_unregister(&watchdog_class);
+err_register:
+       destroy_workqueue(watchdog_wq);
+       return err;
 }
 
 /*
This page took 0.026985 seconds and 5 git commands to generate.