public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwspinlock: Fix incorrect return pointers
@ 2018-06-28  2:32 Baolin Wang
  2018-07-30 11:34 ` Baolin Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Baolin Wang @ 2018-06-28  2:32 UTC (permalink / raw)
  To: ohad, bjorn.andersson
  Cc: broonie, dan.carpenter, linux-remoteproc, linux-kernel,
	baolin.wang

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwspinlock: Fix incorrect return pointers
  2018-06-28  2:32 [PATCH] hwspinlock: Fix incorrect return pointers Baolin Wang
@ 2018-07-30 11:34 ` Baolin Wang
  2018-07-31  4:02   ` Bjorn Andersson
  0 siblings, 1 reply; 3+ messages in thread
From: Baolin Wang @ 2018-07-30 11:34 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: Mark Brown, Dan Carpenter, linux-remoteproc, LKML, Baolin Wang

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwspinlock: Fix incorrect return pointers
  2018-07-30 11:34 ` Baolin Wang
@ 2018-07-31  4:02   ` Bjorn Andersson
  0 siblings, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2018-07-31  4:02 UTC (permalink / raw)
  To: Baolin Wang
  Cc: Ohad Ben-Cohen, Mark Brown, Dan Carpenter, linux-remoteproc, LKML

On Mon 30 Jul 04:34 PDT 2018, Baolin Wang wrote:

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

I thought I had picked this already, it's applied now. Sorry about the
delay.

Regards,
Bjorn

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-31  4:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-28  2:32 [PATCH] hwspinlock: Fix incorrect return pointers Baolin Wang
2018-07-30 11:34 ` Baolin Wang
2018-07-31  4:02   ` Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox