Commit ddb34f48 authored by Baolin Wang's avatar Baolin Wang Committed by Bjorn Andersson

hwspinlock: Fix incorrect return pointers

The commit 4f1acd75 ("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: 's avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: 's avatarBaolin Wang <baolin.wang@linaro.org>
Signed-off-by: 's avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent c8d04989
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment