Skip to content

Commit

Permalink
hwspinlock: Fix incorrect return pointers
Browse files Browse the repository at this point in the history
The commit 4f1acd7 ("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>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
  • Loading branch information
Baolin Wang authored and Bjorn Andersson committed Jul 31, 2018
1 parent c8d0498 commit ddb34f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/hwspinlock/hwspinlock_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ddb34f4

Please sign in to comment.