Commit 138913cb authored by Wei Yongjun's avatar Wei Yongjun Committed by Wim Van Sebroeck

watchdog: core: Fix error handling of watchdog_dev_init()

Fix the error handling paths of watchdog_dev_init().
Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent cddd74db
...@@ -972,17 +972,22 @@ int __init watchdog_dev_init(void) ...@@ -972,17 +972,22 @@ int __init watchdog_dev_init(void)
err = class_register(&watchdog_class); err = class_register(&watchdog_class);
if (err < 0) { if (err < 0) {
pr_err("couldn't register class\n"); pr_err("couldn't register class\n");
return err; goto err_register;
} }
err = alloc_chrdev_region(&watchdog_devt, 0, MAX_DOGS, "watchdog"); err = alloc_chrdev_region(&watchdog_devt, 0, MAX_DOGS, "watchdog");
if (err < 0) { if (err < 0) {
pr_err("watchdog: unable to allocate char dev region\n"); pr_err("watchdog: unable to allocate char dev region\n");
class_unregister(&watchdog_class); goto err_alloc;
return err;
} }
return 0; return 0;
err_alloc:
class_unregister(&watchdog_class);
err_register:
destroy_workqueue(watchdog_wq);
return err;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment