diff mbox series

drm: rcar-du: Fix a NULL vs IS_ERR() bug

Message ID Y/yAw6sHu82OnOWj@kili (mailing list archive)
State New, archived
Headers show
Series drm: rcar-du: Fix a NULL vs IS_ERR() bug | expand

Commit Message

Dan Carpenter Feb. 27, 2023, 10:06 a.m. UTC
The drmm_encoder_alloc() function returns error pointers.  It never
returns NULL.  Fix the check accordingly.

Fixes: 7a1adbd23990 ("drm: rcar-du: Use drmm_encoder_alloc() to manage encoder")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kieran Bingham Feb. 27, 2023, 11:31 a.m. UTC | #1
Quoting Dan Carpenter (2023-02-27 10:06:59)
> The drmm_encoder_alloc() function returns error pointers.  It never
> returns NULL.  Fix the check accordingly.

Yes, indeed. Thanks.

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

> 
> Fixes: 7a1adbd23990 ("drm: rcar-du: Use drmm_encoder_alloc() to manage encoder")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> index b1787be31e92..7ecec7b04a8d 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> @@ -109,8 +109,8 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
>         renc = drmm_encoder_alloc(&rcdu->ddev, struct rcar_du_encoder, base,
>                                   &rcar_du_encoder_funcs, DRM_MODE_ENCODER_NONE,
>                                   NULL);
> -       if (!renc)
> -               return -ENOMEM;
> +       if (IS_ERR(renc))
> +               return PTR_ERR(renc);
>  
>         renc->output = output;
>  
> -- 
> 2.39.1
>
Laurent Pinchart Feb. 27, 2023, 2:38 p.m. UTC | #2
Hi Dan,

Thank you for the patch.

On Mon, Feb 27, 2023 at 01:06:59PM +0300, Dan Carpenter wrote:
> The drmm_encoder_alloc() function returns error pointers.  It never
> returns NULL.  Fix the check accordingly.
> 
> Fixes: 7a1adbd23990 ("drm: rcar-du: Use drmm_encoder_alloc() to manage encoder")
> Signed-off-by: Dan Carpenter <error27@gmail.com>

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

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> index b1787be31e92..7ecec7b04a8d 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> @@ -109,8 +109,8 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
>  	renc = drmm_encoder_alloc(&rcdu->ddev, struct rcar_du_encoder, base,
>  				  &rcar_du_encoder_funcs, DRM_MODE_ENCODER_NONE,
>  				  NULL);
> -	if (!renc)
> -		return -ENOMEM;
> +	if (IS_ERR(renc))
> +		return PTR_ERR(renc);
>  
>  	renc->output = output;
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
index b1787be31e92..7ecec7b04a8d 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -109,8 +109,8 @@  int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 	renc = drmm_encoder_alloc(&rcdu->ddev, struct rcar_du_encoder, base,
 				  &rcar_du_encoder_funcs, DRM_MODE_ENCODER_NONE,
 				  NULL);
-	if (!renc)
-		return -ENOMEM;
+	if (IS_ERR(renc))
+		return PTR_ERR(renc);
 
 	renc->output = output;