From: Baolin Wang <baolin.wang@linaro.org>
To: ohad@wizery.com, bjorn.andersson@linaro.org
Cc: broonie@kernel.org, dan.carpenter@oracle.com,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
baolin.wang@linaro.org
Subject: [PATCH] hwspinlock: Fix incorrect return pointers
Date: Thu, 28 Jun 2018 10:32:21 +0800 [thread overview]
Message-ID: <782fc498b4f4c6e8130d64face93023eb3dc9866.1530152980.git.baolin.wang@linaro.org> (raw)
The commit 4f1acd758b08 ("hwspinlock: Add devm_xxx() APIs to request/free
hwlock") introduces one bug, that will return one error pointer if failed
to request one hwlock, but we expect NULL pointer on error for consumers.
This patch will fix this issue.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
drivers/hwspinlock/hwspinlock_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c
index e16d648..2bad40d 100644
--- a/drivers/hwspinlock/hwspinlock_core.c
+++ b/drivers/hwspinlock/hwspinlock_core.c
@@ -877,10 +877,10 @@ struct hwspinlock *devm_hwspin_lock_request(struct device *dev)
ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
- return ERR_PTR(-ENOMEM);
+ return NULL;
hwlock = hwspin_lock_request();
- if (!IS_ERR(hwlock)) {
+ if (hwlock) {
*ptr = hwlock;
devres_add(dev, ptr);
} else {
@@ -913,10 +913,10 @@ struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev,
ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
- return ERR_PTR(-ENOMEM);
+ return NULL;
hwlock = hwspin_lock_request_specific(id);
- if (!IS_ERR(hwlock)) {
+ if (hwlock) {
*ptr = hwlock;
devres_add(dev, ptr);
} else {
--
1.7.9.5
next reply other threads:[~2018-06-28 2:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-28 2:32 Baolin Wang [this message]
2018-07-30 11:34 ` Baolin Wang
2018-07-31 4:02 ` Bjorn Andersson
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=782fc498b4f4c6e8130d64face93023eb3dc9866.1530152980.git.baolin.wang@linaro.org \
--to=baolin.wang@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=ohad@wizery.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®