All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
@ 2020-11-11  3:14 ` Wang Xiaojun
  0 siblings, 0 replies; 8+ messages in thread
From: Wang Xiaojun @ 2020-11-11  3:14 UTC (permalink / raw)
  To: laurent.pinchart, kieran.bingham+renesas, airlied, daniel
  Cc: dri-devel, linux-renesas-soc

of_parse_phandle and of_find_device_by_node may return NULL
which cannot be checked by IS_ERR.

Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 72dda446355f..fcfddf7ad3f3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		int ret;
 
 		cmm = of_parse_phandle(np, "renesas,cmms", i);
-		if (IS_ERR(cmm)) {
+		if (!cmm) {
 			dev_err(rcdu->dev,
 				"Failed to parse 'renesas,cmms' property\n");
-			return PTR_ERR(cmm);
+			return -ENODEV;
 		}
 
 		if (!of_device_is_available(cmm)) {
@@ -713,10 +713,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		}
 
 		pdev = of_find_device_by_node(cmm);
-		if (IS_ERR(pdev)) {
+		if (!pdev) {
 			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
 			of_node_put(cmm);
-			return PTR_ERR(pdev);
+			return -ENODEV;
 		}
 
 		of_node_put(cmm);
-- 
2.25.1


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

* [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
@ 2020-11-11  3:14 ` Wang Xiaojun
  0 siblings, 0 replies; 8+ messages in thread
From: Wang Xiaojun @ 2020-11-11  3:14 UTC (permalink / raw)
  To: laurent.pinchart, kieran.bingham+renesas, airlied, daniel
  Cc: linux-renesas-soc, dri-devel

of_parse_phandle and of_find_device_by_node may return NULL
which cannot be checked by IS_ERR.

Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 72dda446355f..fcfddf7ad3f3 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		int ret;
 
 		cmm = of_parse_phandle(np, "renesas,cmms", i);
-		if (IS_ERR(cmm)) {
+		if (!cmm) {
 			dev_err(rcdu->dev,
 				"Failed to parse 'renesas,cmms' property\n");
-			return PTR_ERR(cmm);
+			return -ENODEV;
 		}
 
 		if (!of_device_is_available(cmm)) {
@@ -713,10 +713,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		}
 
 		pdev = of_find_device_by_node(cmm);
-		if (IS_ERR(pdev)) {
+		if (!pdev) {
 			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
 			of_node_put(cmm);
-			return PTR_ERR(pdev);
+			return -ENODEV;
 		}
 
 		of_node_put(cmm);
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
  2020-11-11  3:14 ` Wang Xiaojun
@ 2020-11-11 12:51   ` Kieran Bingham
  -1 siblings, 0 replies; 8+ messages in thread
From: Kieran Bingham @ 2020-11-11 12:51 UTC (permalink / raw)
  To: Wang Xiaojun, laurent.pinchart, airlied, daniel
  Cc: dri-devel, linux-renesas-soc

Hi Wang Xiaojun,

On 11/11/2020 03:14, Wang Xiaojun wrote:
> of_parse_phandle and of_find_device_by_node may return NULL
> which cannot be checked by IS_ERR.

Indeed, both of these functions return either NULL or the correct value,
and no an errno.

> 
> Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
> Reported-by: Hulk Robot <hulkci@huawei.com>

Fixes: 8de707aeb452 ("drm: rcar-du: kms: Initialize CMM instances")

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> index 72dda446355f..fcfddf7ad3f3 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
>  		int ret;
>  
>  		cmm = of_parse_phandle(np, "renesas,cmms", i);
> -		if (IS_ERR(cmm)) {
> +		if (!cmm) {
>  			dev_err(rcdu->dev,
>  				"Failed to parse 'renesas,cmms' property\n");
> -			return PTR_ERR(cmm);
> +			return -ENODEV;
>  		}
>  
>  		if (!of_device_is_available(cmm)) {
> @@ -713,10 +713,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
>  		}
>  
>  		pdev = of_find_device_by_node(cmm);
> -		if (IS_ERR(pdev)) {
> +		if (!pdev) {
>  			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
>  			of_node_put(cmm);
> -			return PTR_ERR(pdev);
> +			return -ENODEV;
>  		}
>  
>  		of_node_put(cmm);
> 


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

* Re: [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
@ 2020-11-11 12:51   ` Kieran Bingham
  0 siblings, 0 replies; 8+ messages in thread
From: Kieran Bingham @ 2020-11-11 12:51 UTC (permalink / raw)
  To: Wang Xiaojun, laurent.pinchart, airlied, daniel
  Cc: linux-renesas-soc, dri-devel

Hi Wang Xiaojun,

On 11/11/2020 03:14, Wang Xiaojun wrote:
> of_parse_phandle and of_find_device_by_node may return NULL
> which cannot be checked by IS_ERR.

Indeed, both of these functions return either NULL or the correct value,
and no an errno.

> 
> Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
> Reported-by: Hulk Robot <hulkci@huawei.com>

Fixes: 8de707aeb452 ("drm: rcar-du: kms: Initialize CMM instances")

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> index 72dda446355f..fcfddf7ad3f3 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
>  		int ret;
>  
>  		cmm = of_parse_phandle(np, "renesas,cmms", i);
> -		if (IS_ERR(cmm)) {
> +		if (!cmm) {
>  			dev_err(rcdu->dev,
>  				"Failed to parse 'renesas,cmms' property\n");
> -			return PTR_ERR(cmm);
> +			return -ENODEV;
>  		}
>  
>  		if (!of_device_is_available(cmm)) {
> @@ -713,10 +713,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
>  		}
>  
>  		pdev = of_find_device_by_node(cmm);
> -		if (IS_ERR(pdev)) {
> +		if (!pdev) {
>  			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
>  			of_node_put(cmm);
> -			return PTR_ERR(pdev);
> +			return -ENODEV;
>  		}
>  
>  		of_node_put(cmm);
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
  2020-11-11  3:14 ` Wang Xiaojun
@ 2020-12-16  1:00   ` Laurent Pinchart
  -1 siblings, 0 replies; 8+ messages in thread
From: Laurent Pinchart @ 2020-12-16  1:00 UTC (permalink / raw)
  To: Wang Xiaojun
  Cc: kieran.bingham+renesas, airlied, daniel, dri-devel, linux-renesas-soc

Hi Wang,

Thank you for the patch.

On Wed, Nov 11, 2020 at 11:14:52AM +0800, Wang Xiaojun wrote:
> of_parse_phandle and of_find_device_by_node may return NULL
> which cannot be checked by IS_ERR.
> 
> Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
> Reported-by: Hulk Robot <hulkci@huawei.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

and queued in my tree for v5.12.

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> index 72dda446355f..fcfddf7ad3f3 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
>  		int ret;
>  
>  		cmm = of_parse_phandle(np, "renesas,cmms", i);
> -		if (IS_ERR(cmm)) {
> +		if (!cmm) {
>  			dev_err(rcdu->dev,
>  				"Failed to parse 'renesas,cmms' property\n");
> -			return PTR_ERR(cmm);
> +			return -ENODEV;
>  		}
>  
>  		if (!of_device_is_available(cmm)) {
> @@ -713,10 +713,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
>  		}
>  
>  		pdev = of_find_device_by_node(cmm);
> -		if (IS_ERR(pdev)) {
> +		if (!pdev) {
>  			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
>  			of_node_put(cmm);
> -			return PTR_ERR(pdev);
> +			return -ENODEV;
>  		}
>  
>  		of_node_put(cmm);

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
@ 2020-12-16  1:00   ` Laurent Pinchart
  0 siblings, 0 replies; 8+ messages in thread
From: Laurent Pinchart @ 2020-12-16  1:00 UTC (permalink / raw)
  To: Wang Xiaojun
  Cc: airlied, linux-renesas-soc, kieran.bingham+renesas, dri-devel

Hi Wang,

Thank you for the patch.

On Wed, Nov 11, 2020 at 11:14:52AM +0800, Wang Xiaojun wrote:
> of_parse_phandle and of_find_device_by_node may return NULL
> which cannot be checked by IS_ERR.
> 
> Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
> Reported-by: Hulk Robot <hulkci@huawei.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

and queued in my tree for v5.12.

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> index 72dda446355f..fcfddf7ad3f3 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
>  		int ret;
>  
>  		cmm = of_parse_phandle(np, "renesas,cmms", i);
> -		if (IS_ERR(cmm)) {
> +		if (!cmm) {
>  			dev_err(rcdu->dev,
>  				"Failed to parse 'renesas,cmms' property\n");
> -			return PTR_ERR(cmm);
> +			return -ENODEV;
>  		}
>  
>  		if (!of_device_is_available(cmm)) {
> @@ -713,10 +713,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
>  		}
>  
>  		pdev = of_find_device_by_node(cmm);
> -		if (IS_ERR(pdev)) {
> +		if (!pdev) {
>  			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
>  			of_node_put(cmm);
> -			return PTR_ERR(pdev);
> +			return -ENODEV;
>  		}
>  
>  		of_node_put(cmm);

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
  2020-12-16  1:00   ` Laurent Pinchart
@ 2020-12-16  1:05     ` Laurent Pinchart
  -1 siblings, 0 replies; 8+ messages in thread
From: Laurent Pinchart @ 2020-12-16  1:05 UTC (permalink / raw)
  To: Wang Xiaojun
  Cc: kieran.bingham+renesas, airlied, daniel, dri-devel, linux-renesas-soc

On Wed, Dec 16, 2020 at 03:00:43AM +0200, Laurent Pinchart wrote:
> Hi Wang,
> 
> Thank you for the patch.
> 
> On Wed, Nov 11, 2020 at 11:14:52AM +0800, Wang Xiaojun wrote:
> > of_parse_phandle and of_find_device_by_node may return NULL
> > which cannot be checked by IS_ERR.
> > 
> > Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> and queued in my tree for v5.12.
> 
> > ---
> >  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > index 72dda446355f..fcfddf7ad3f3 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > @@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
> >  		int ret;
> >  
> >  		cmm = of_parse_phandle(np, "renesas,cmms", i);
> > -		if (IS_ERR(cmm)) {
> > +		if (!cmm) {
> >  			dev_err(rcdu->dev,
> >  				"Failed to parse 'renesas,cmms' property\n");
> > -			return PTR_ERR(cmm);
> > +			return -ENODEV;

Actually, this should return -EINVAL, as this error really shouldn't
happen. Same below. I'll update this, no need to resend a new version.

> >  		}
> >  
> >  		if (!of_device_is_available(cmm)) {
> > @@ -713,10 +713,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
> >  		}
> >  
> >  		pdev = of_find_device_by_node(cmm);
> > -		if (IS_ERR(pdev)) {
> > +		if (!pdev) {
> >  			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
> >  			of_node_put(cmm);
> > -			return PTR_ERR(pdev);
> > +			return -ENODEV;
> >  		}
> >  
> >  		of_node_put(cmm);

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node
@ 2020-12-16  1:05     ` Laurent Pinchart
  0 siblings, 0 replies; 8+ messages in thread
From: Laurent Pinchart @ 2020-12-16  1:05 UTC (permalink / raw)
  To: Wang Xiaojun
  Cc: airlied, linux-renesas-soc, kieran.bingham+renesas, dri-devel

On Wed, Dec 16, 2020 at 03:00:43AM +0200, Laurent Pinchart wrote:
> Hi Wang,
> 
> Thank you for the patch.
> 
> On Wed, Nov 11, 2020 at 11:14:52AM +0800, Wang Xiaojun wrote:
> > of_parse_phandle and of_find_device_by_node may return NULL
> > which cannot be checked by IS_ERR.
> > 
> > Signed-off-by: Wang Xiaojun <wangxiaojun11@huawei.com>
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> and queued in my tree for v5.12.
> 
> > ---
> >  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > index 72dda446355f..fcfddf7ad3f3 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> > @@ -700,10 +700,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
> >  		int ret;
> >  
> >  		cmm = of_parse_phandle(np, "renesas,cmms", i);
> > -		if (IS_ERR(cmm)) {
> > +		if (!cmm) {
> >  			dev_err(rcdu->dev,
> >  				"Failed to parse 'renesas,cmms' property\n");
> > -			return PTR_ERR(cmm);
> > +			return -ENODEV;

Actually, this should return -EINVAL, as this error really shouldn't
happen. Same below. I'll update this, no need to resend a new version.

> >  		}
> >  
> >  		if (!of_device_is_available(cmm)) {
> > @@ -713,10 +713,10 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
> >  		}
> >  
> >  		pdev = of_find_device_by_node(cmm);
> > -		if (IS_ERR(pdev)) {
> > +		if (!pdev) {
> >  			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
> >  			of_node_put(cmm);
> > -			return PTR_ERR(pdev);
> > +			return -ENODEV;
> >  		}
> >  
> >  		of_node_put(cmm);

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2020-12-16  1:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11  3:14 [PATCH] drm: rcar-du: Fix the return check of of_parse_phandle and of_find_device_by_node Wang Xiaojun
2020-11-11  3:14 ` Wang Xiaojun
2020-11-11 12:51 ` Kieran Bingham
2020-11-11 12:51   ` Kieran Bingham
2020-12-16  1:00 ` Laurent Pinchart
2020-12-16  1:00   ` Laurent Pinchart
2020-12-16  1:05   ` Laurent Pinchart
2020-12-16  1:05     ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.