diff options
author | Baolin Wang <baolin.wang@linaro.org> | 2018-06-28 04:32:21 +0200 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-07-31 05:54:51 +0200 |
commit | ddb34f480d1b8051bc18e6ff22e93a6c9a33f94f (patch) | |
tree | c34af11c5e0a134259a63c3ae10f56203dc21e31 /drivers | |
parent | spi: sprd: Change to use devm_hwspin_lock_request_specific() (diff) | |
download | linux-ddb34f480d1b8051bc18e6ff22e93a6c9a33f94f.tar.xz linux-ddb34f480d1b8051bc18e6ff22e93a6c9a33f94f.zip |
hwspinlock: Fix incorrect return pointers
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>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwspinlock/hwspinlock_core.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index e16d648c30f3..2bad40d42210 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 { |