From: Wang Wensheng <wangwensheng4@huawei.com>
To: <wim@linux-watchdog.org>, <linux@roeck-us.net>,
<linux-watchdog@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <rui.xiang@huawei.com>, <guohanjun@huawei.com>
Subject: [PATCH -next v2 1/2] watchdog: Clean up error handlings of __watchdog_register_device
Date: Tue, 3 Nov 2020 06:52:16 +0000 [thread overview]
Message-ID: <20201103065217.67876-1-wangwensheng4@huawei.com> (raw)
Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
---
drivers/watchdog/watchdog_core.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 423844757812..c73871f41142 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -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. */
@@ -273,9 +271,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;
}
}
@@ -289,6 +285,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;
}
/**
--
2.25.0
next reply other threads:[~2020-11-03 6:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 6:52 Wang Wensheng [this message]
2020-11-03 6:52 ` [PATCH -next v2 2/2] watchdog: Fix potential dereferencing of null pointer Wang Wensheng
2020-11-03 7:05 ` [PATCH -next v2 1/2] watchdog: Clean up error handlings of __watchdog_register_device Christophe Leroy
2020-11-03 13:05 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201103065217.67876-1-wangwensheng4@huawei.com \
--to=wangwensheng4@huawei.com \
--cc=guohanjun@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=rui.xiang@huawei.com \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.