* [PATCH v3] drm: panel-lvds: Potential Oops in probe error handling
@ 2019-09-11 10:49 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2019-09-11 10:49 UTC (permalink / raw)
To: Thierry Reding, Laurent Pinchart
Cc: David Airlie, kernel-janitors, Liam Girdwood, dri-devel,
Mark Brown, Sam Ravnborg
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: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v3: Use devm_of_find_backlight(). This version is quite a bit more
ambitious, and I haven't tested it so please review carefully.
v2: Use backlight_put()
drivers/gpu/drm/panel/panel-lvds.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c
index ad47cc95459e..bf5fcc3e5379 100644
--- a/drivers/gpu/drm/panel/panel-lvds.c
+++ b/drivers/gpu/drm/panel/panel-lvds.c
@@ -197,7 +197,6 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds)
static int panel_lvds_probe(struct platform_device *pdev)
{
struct panel_lvds *lvds;
- struct device_node *np;
int ret;
lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
@@ -243,14 +242,9 @@ static int panel_lvds_probe(struct platform_device *pdev)
return ret;
}
- np = of_parse_phandle(lvds->dev->of_node, "backlight", 0);
- if (np) {
- lvds->backlight = of_find_backlight_by_node(np);
- of_node_put(np);
-
- if (!lvds->backlight)
- return -EPROBE_DEFER;
- }
+ lvds->backlight = devm_of_find_backlight(lvds->dev);
+ if (IS_ERR(lvds->backlight))
+ return PTR_ERR(lvds->backlight);
/*
* TODO: Handle all power supplies specified in the DT node in a generic
@@ -266,14 +260,10 @@ static int panel_lvds_probe(struct platform_device *pdev)
ret = drm_panel_add(&lvds->panel);
if (ret < 0)
- goto error;
+ return ret;
dev_set_drvdata(lvds->dev, lvds);
return 0;
-
-error:
- put_device(&lvds->backlight->dev);
- return ret;
}
static int panel_lvds_remove(struct platform_device *pdev)
@@ -284,9 +274,6 @@ static int panel_lvds_remove(struct platform_device *pdev)
panel_lvds_disable(&lvds->panel);
- if (lvds->backlight)
- put_device(&lvds->backlight->dev);
-
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3] drm: panel-lvds: Potential Oops in probe error handling
@ 2019-09-11 10:49 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2019-09-11 10:49 UTC (permalink / raw)
To: Thierry Reding, Laurent Pinchart
Cc: David Airlie, kernel-janitors, Liam Girdwood, dri-devel,
Mark Brown, Sam Ravnborg
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: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v3: Use devm_of_find_backlight(). This version is quite a bit more
ambitious, and I haven't tested it so please review carefully.
v2: Use backlight_put()
drivers/gpu/drm/panel/panel-lvds.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c
index ad47cc95459e..bf5fcc3e5379 100644
--- a/drivers/gpu/drm/panel/panel-lvds.c
+++ b/drivers/gpu/drm/panel/panel-lvds.c
@@ -197,7 +197,6 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds)
static int panel_lvds_probe(struct platform_device *pdev)
{
struct panel_lvds *lvds;
- struct device_node *np;
int ret;
lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
@@ -243,14 +242,9 @@ static int panel_lvds_probe(struct platform_device *pdev)
return ret;
}
- np = of_parse_phandle(lvds->dev->of_node, "backlight", 0);
- if (np) {
- lvds->backlight = of_find_backlight_by_node(np);
- of_node_put(np);
-
- if (!lvds->backlight)
- return -EPROBE_DEFER;
- }
+ lvds->backlight = devm_of_find_backlight(lvds->dev);
+ if (IS_ERR(lvds->backlight))
+ return PTR_ERR(lvds->backlight);
/*
* TODO: Handle all power supplies specified in the DT node in a generic
@@ -266,14 +260,10 @@ static int panel_lvds_probe(struct platform_device *pdev)
ret = drm_panel_add(&lvds->panel);
if (ret < 0)
- goto error;
+ return ret;
dev_set_drvdata(lvds->dev, lvds);
return 0;
-
-error:
- put_device(&lvds->backlight->dev);
- return ret;
}
static int panel_lvds_remove(struct platform_device *pdev)
@@ -284,9 +274,6 @@ static int panel_lvds_remove(struct platform_device *pdev)
panel_lvds_disable(&lvds->panel);
- if (lvds->backlight)
- put_device(&lvds->backlight->dev);
-
return 0;
}
--
2.20.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] drm: panel-lvds: Potential Oops in probe error handling
2019-09-11 10:49 ` Dan Carpenter
@ 2019-09-21 18:55 ` Sam Ravnborg
-1 siblings, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2019-09-21 18:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: Laurent Pinchart, David Airlie, kernel-janitors, Liam Girdwood,
dri-devel, Mark Brown, Thierry Reding
Hi Dan.
On Wed, Sep 11, 2019 at 01:49:28PM +0300, Dan Carpenter wrote:
> 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: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v3: Use devm_of_find_backlight(). This version is quite a bit more
> ambitious, and I haven't tested it so please review carefully.
Looks good.
Applied and pushed to drm-misc-next.
It will hit upstream not at this but next merge window.
Sam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] drm: panel-lvds: Potential Oops in probe error handling
@ 2019-09-21 18:55 ` Sam Ravnborg
0 siblings, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2019-09-21 18:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: Laurent Pinchart, David Airlie, kernel-janitors, Liam Girdwood,
dri-devel, Mark Brown, Thierry Reding
Hi Dan.
On Wed, Sep 11, 2019 at 01:49:28PM +0300, Dan Carpenter wrote:
> 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: 7c9dff5bd643 ("drm: panels: Add LVDS panel driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v3: Use devm_of_find_backlight(). This version is quite a bit more
> ambitious, and I haven't tested it so please review carefully.
Looks good.
Applied and pushed to drm-misc-next.
It will hit upstream not at this but next merge window.
Sam
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-21 18:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11 10:49 [PATCH v3] drm: panel-lvds: Potential Oops in probe error handling Dan Carpenter
2019-09-11 10:49 ` Dan Carpenter
2019-09-21 18:55 ` Sam Ravnborg
2019-09-21 18:55 ` Sam Ravnborg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.