diff mbox series

[v2] drm: panel-lvds: Potential Oops in probe error handling

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

Commit Message

Dan Carpenter Sept. 4, 2019, 6:55 p.m. UTC
The "lvds->backlight" pointer could be NULL in situations were
of_parse_phandle() returns NULL.  Also it's slightly cleaner to use
backlight_put() which already has a check for NULL built in.

Fixes: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Use backlight_put().  Thanks, Laurent!

 drivers/gpu/drm/panel/panel-lvds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Sept. 4, 2019, 9:48 p.m. UTC | #1
Hi Dan,

Thank you for the patch.

On Wed, Sep 04, 2019 at 09:55:07PM +0300, Dan Carpenter wrote:
> The "lvds->backlight" pointer could be NULL in situations were
> of_parse_phandle() returns NULL.  Also it's slightly cleaner to use
> backlight_put() which already has a check for NULL built in.
> 
> Fixes: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

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

Sam, would you be able to pick this patch ?

> ---
> v2: Use backlight_put().  Thanks, Laurent!
> 
>  drivers/gpu/drm/panel/panel-lvds.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c
> index ad47cc95459e..05e8885db7ed 100644
> --- a/drivers/gpu/drm/panel/panel-lvds.c
> +++ b/drivers/gpu/drm/panel/panel-lvds.c
> @@ -272,7 +272,7 @@ static int panel_lvds_probe(struct platform_device *pdev)
>  	return 0;
>  
>  error:
> -	put_device(&lvds->backlight->dev);
> +	backlight_put(lvds->backlight);
>  	return ret;
>  }
>
Sam Ravnborg Sept. 8, 2019, 4:04 p.m. UTC | #2
Hi Dan.

On Wed, Sep 04, 2019 at 09:55:07PM +0300, Dan Carpenter wrote:
> The "lvds->backlight" pointer could be NULL in situations were
> of_parse_phandle() returns NULL.  Also it's slightly cleaner to use
> backlight_put() which already has a check for NULL built in.
> 
> Fixes: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

A much better fix would be to introduce use of devm_of_find_backlight().
Then you do not have to worry about put().

Care to respin a v3 that does this?

	Sam
Dan Carpenter Sept. 10, 2019, 1:32 p.m. UTC | #3
On Sun, Sep 08, 2019 at 06:04:28PM +0200, Sam Ravnborg wrote:
> Hi Dan.
> 
> On Wed, Sep 04, 2019 at 09:55:07PM +0300, Dan Carpenter wrote:
> > The "lvds->backlight" pointer could be NULL in situations were
> > of_parse_phandle() returns NULL.  Also it's slightly cleaner to use
> > backlight_put() which already has a check for NULL built in.
> > 
> > Fixes: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> A much better fix would be to introduce use of devm_of_find_backlight().
> Then you do not have to worry about put().
> 
> Care to respin a v3 that does this?

Sure.  That does look nice.  I will resend tomorrow.

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..05e8885db7ed 100644
--- a/drivers/gpu/drm/panel/panel-lvds.c
+++ b/drivers/gpu/drm/panel/panel-lvds.c
@@ -272,7 +272,7 @@  static int panel_lvds_probe(struct platform_device *pdev)
 	return 0;
 
 error:
-	put_device(&lvds->backlight->dev);
+	backlight_put(lvds->backlight);
 	return ret;
 }