Skip to contentSkip to conversation

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

PATCH Superseded Dan Carpenter 3 participants 7 messages Sep 4, 2019 – Sep 10, 2019

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: panel-lvds: Potential Oops in probe error handling

The "lvds->backlight" pointer could be NULl if of_parse_phandle() returns NULL.

Fixes 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
---
 drivers/gpu/drm/panel/panel-lvds.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-lvds.c +2 -1
index ad47cc95459e..3b4eb959e994 100644
@@ -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;
 }
 
Signature · 1 line
2.20.1
maintainer
#1 lore raw

Hi Dan,

Thank you for the patch.

Quoted 14 lines · Dan Carpenter

The "lvds->backlight" pointer could be NULl if of_parse_phandle() returns NULL.

Fixes 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
---
 drivers/gpu/drm/panel/panel-lvds.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-lvds.c +0 -0
index ad47cc95459e..3b4eb959e994 100644

drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device *pdev) · line 276

Quoted 6 lines
drivers/gpu/drm/panel/panel-lvds.c +2 -1
@@ -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);

?

Quoted 3 lines
drivers/gpu/drm/panel/panel-lvds.c +0 -0
 	return ret;
 }
 
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw

Review

Quoted 9 lines · Laurent Pinchart

drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device *pdev) · line 276

Quoted 4 lines

error:

drivers/gpu/drm/panel/panel-lvds.c +2 -1
-	put_device(&lvds->backlight->dev);
+	if (lvds->backlight)
+		put_device(&lvds->backlight->dev);

How about simply

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

Yeah. That's cleaner. I will resend.

regards,
dan carpenter

#3 lore raw

PATCH v2 1/1 drm: panel-lvds: Potential Oops in probe error handling

In reply to Laurent Pinchart

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

---
v2: Use backlight_put(). Thanks, Laurent!

 drivers/gpu/drm/panel/panel-lvds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-lvds.c +1 -1
index ad47cc95459e..05e8885db7ed 100644
@@ -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;
 }
 
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 1/1
#4 lore raw

Hi Dan,

Thank you for the patch.

Quoted 6 lines · Dan Carpenter

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

Sam, would you be able to pick this patch ?

Quoted 19 lines

---
v2: Use backlight_put(). Thanks, Laurent!

 drivers/gpu/drm/panel/panel-lvds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-lvds.c +1 -1
index ad47cc95459e..05e8885db7ed 100644
@@ -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;
 }
 
Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw
In reply to Dan Carpenter

Hi Dan.

Quoted 6 lines · Dan Carpenter

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

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

#6 lore raw
Quoted 7 lines · Sam Ravnborg

Hi Dan.

Quoted 4 lines · Dan Carpenter

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.

Quoted 7 lines
Quoted 2 lines
Fixes 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")

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