@@ -252,10 +252,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
wdd->id = id;
ret = watchdog_dev_register(wdd);
- if (ret) {
- ida_simple_remove(&watchdog_ida, id);
- return ret;
- }
+ if (ret)
+ goto id_remove;
}
/* Module parameter to force watchdog policy on reboot. */
@@ -270,9 +268,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
if (!wdd->ops->stop) {
pr_err("watchdog%d: Cannot support stop_on_reboot\n",
wdd->id);
- watchdog_dev_unregister(wdd);
- ida_simple_remove(&watchdog_ida, id);
- return -EINVAL;
+ ret = -EINVAL;
+ goto dev_unregister;
}
wdd->reboot_nb.notifier_call = watchdog_reboot_notifier;
@@ -280,9 +277,7 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
if (ret) {
pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
wdd->id, ret);
- watchdog_dev_unregister(wdd);
- ida_simple_remove(&watchdog_ida, id);
- return ret;
+ goto dev_unregister;
}
}
@@ -296,6 +291,13 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
}
return 0;
+
+dev_unregister:
+ watchdog_dev_unregister(wdd);
+id_remove:
+ ida_simple_remove(&watchdog_ida, id);
+
+ return ret;
}
/**
Clean up the repeated error handling process in function __watchdog_register_device(). Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com> --- drivers/watchdog/watchdog_core.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)