diff mbox series

drm: panel-lvds: Potential Oops in probe error handling

Message ID 20190904100329.GE7007@mwanda (mailing list archive)
State New, archived
Headers show
Series drm: panel-lvds: Potential Oops in probe error handling | expand

Commit Message

Dan Carpenter Sept. 4, 2019, 10:03 a.m. UTC
The "lvds->backlight" pointer could be NULl if of_parse_phandle()
returns NULL.

Fixes: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/gpu/drm/panel/panel-lvds.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Sept. 4, 2019, 11:50 a.m. UTC | #1
Hi Dan,

Thank you for the patch.

On Wed, Sep 04, 2019 at 01:03:29PM +0300, Dan Carpenter wrote:
> The "lvds->backlight" pointer could be NULl if of_parse_phandle()
> returns NULL.
> 
> Fixes: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/gpu/drm/panel/panel-lvds.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c
> index ad47cc95459e..3b4eb959e994 100644
> --- a/drivers/gpu/drm/panel/panel-lvds.c
> +++ b/drivers/gpu/drm/panel/panel-lvds.c
> @@ -272,7 +272,8 @@ static int panel_lvds_probe(struct platform_device *pdev)
>  	return 0;
>  
>  error:
> -	put_device(&lvds->backlight->dev);
> +	if (lvds->backlight)
> +		put_device(&lvds->backlight->dev);

How about simply

-	put_device(&lvds->backlight->dev);
+	backlight_put(lvds->backlight);

?

>  	return ret;
>  }
>
Dan Carpenter Sept. 4, 2019, 12:57 p.m. UTC | #2
On Wed, Sep 04, 2019 at 02:50:57PM +0300, Laurent Pinchart wrote:
> >  error:
> > -	put_device(&lvds->backlight->dev);
> > +	if (lvds->backlight)
> > +		put_device(&lvds->backlight->dev);
> 
> How about simply
> 
> -	put_device(&lvds->backlight->dev);
> +	backlight_put(lvds->backlight);

Yeah.  That's cleaner.  I will resend.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c
index ad47cc95459e..3b4eb959e994 100644
--- a/drivers/gpu/drm/panel/panel-lvds.c
+++ b/drivers/gpu/drm/panel/panel-lvds.c
@@ -272,7 +272,8 @@  static int panel_lvds_probe(struct platform_device *pdev)
 	return 0;
 
 error:
-	put_device(&lvds->backlight->dev);
+	if (lvds->backlight)
+		put_device(&lvds->backlight->dev);
 	return ret;
 }