lkml.org 
[lkml]   [2018]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] hwspinlock: Fix incorrect return pointers
Hi Bjorn,

On 28 June 2018 at 10:32, Baolin Wang <baolin.wang@linaro.org> wrote:
> 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>

Could you pick up this patch which fixes the incorrect return value
issue? Thanks.

> ---
> 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
>



--
Baolin Wang
Best Regards

\
 
 \ /
  Last update: 2018-07-30 13:34    [W:0.068 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site