]> Git Repo - linux.git/commitdiff
hwspinlock: Fix incorrect return pointers
authorBaolin Wang <[email protected]>
Thu, 28 Jun 2018 02:32:21 +0000 (10:32 +0800)
committerBjorn Andersson <[email protected]>
Tue, 31 Jul 2018 03:54:51 +0000 (20:54 -0700)
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 <[email protected]>
Signed-off-by: Baolin Wang <[email protected]>
Signed-off-by: Bjorn Andersson <[email protected]>
drivers/hwspinlock/hwspinlock_core.c

index e16d648c30f3b49f226c990a13ab4af83e485453..2bad40d42210dbe2250caae353e600fae090dd50 100644 (file)
@@ -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 {
This page took 0.062934 seconds and 4 git commands to generate.