Commit fb2ee9bf authored by Dan Carpenter's avatar Dan Carpenter Committed by Sam Ravnborg

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

The "lvds->backlight" pointer could be NULL in situations where
of_parse_phandle() returns NULL.  This code is cleaner if we use the
managed devm_of_find_backlight() so the clean up is automatic.

Fixes: 7c9dff5b ("drm: panels: Add LVDS panel driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190911104928.GA15930@mwanda
parent 21185a66
...@@ -197,7 +197,6 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds) ...@@ -197,7 +197,6 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds)
static int panel_lvds_probe(struct platform_device *pdev) static int panel_lvds_probe(struct platform_device *pdev)
{ {
struct panel_lvds *lvds; struct panel_lvds *lvds;
struct device_node *np;
int ret; int ret;
lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL); lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
...@@ -243,14 +242,9 @@ static int panel_lvds_probe(struct platform_device *pdev) ...@@ -243,14 +242,9 @@ static int panel_lvds_probe(struct platform_device *pdev)
return ret; return ret;
} }
np = of_parse_phandle(lvds->dev->of_node, "backlight", 0); lvds->backlight = devm_of_find_backlight(lvds->dev);
if (np) { if (IS_ERR(lvds->backlight))
lvds->backlight = of_find_backlight_by_node(np); return PTR_ERR(lvds->backlight);
of_node_put(np);
if (!lvds->backlight)
return -EPROBE_DEFER;
}
/* /*
* TODO: Handle all power supplies specified in the DT node in a generic * TODO: Handle all power supplies specified in the DT node in a generic
...@@ -265,14 +259,10 @@ static int panel_lvds_probe(struct platform_device *pdev) ...@@ -265,14 +259,10 @@ static int panel_lvds_probe(struct platform_device *pdev)
ret = drm_panel_add(&lvds->panel); ret = drm_panel_add(&lvds->panel);
if (ret < 0) if (ret < 0)
goto error; return ret;
dev_set_drvdata(lvds->dev, lvds); dev_set_drvdata(lvds->dev, lvds);
return 0; return 0;
error:
put_device(&lvds->backlight->dev);
return ret;
} }
static int panel_lvds_remove(struct platform_device *pdev) static int panel_lvds_remove(struct platform_device *pdev)
...@@ -283,9 +273,6 @@ static int panel_lvds_remove(struct platform_device *pdev) ...@@ -283,9 +273,6 @@ static int panel_lvds_remove(struct platform_device *pdev)
panel_lvds_disable(&lvds->panel); panel_lvds_disable(&lvds->panel);
if (lvds->backlight)
put_device(&lvds->backlight->dev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment