Skip to contentSkip to conversation

drm/imx: dw_hdmi-imx: Fix bailout in error cases of probe

PATCH Applied Liu Ying 2 participants 3 messages Jan 28, 2022 – Mar 29, 2022

Subsystems (3)
lore
Share & tools
lore

Liu Ying

author
#0 lore raw

PATCH 1/1 drm/imx: dw_hdmi-imx: Fix bailout in error cases of probe

In dw_hdmi_imx_probe(), if error happens after dw_hdmi_probe() returns successfully, dw_hdmi_remove() should be called where necessary as bailout.

Fixes c805ec7eb210 ("drm/imx: dw_hdmi-imx: move initialization into probe")
Cc Philipp Zabel <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>
---
 drivers/gpu/drm/imx/dw_hdmi-imx.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/dw_hdmi-imx.c +7 -1
index 87428fb23d9f..a2277a0d6d06 100644
@@ -222,6 +222,7 @@ static int dw_hdmi_imx_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	const struct of_device_id *match = of_match_node(dw_hdmi_imx_dt_ids, np);
 	struct imx_hdmi *hdmi;
+	int ret;
 
 	hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
 	if (!hdmi)
@@ -243,10 +244,15 @@ static int dw_hdmi_imx_probe(struct platform_device *pdev)
 	hdmi->bridge = of_drm_find_bridge(np);
 	if (!hdmi->bridge) {
 		dev_err(hdmi->dev, "Unable to find bridge\n");
+		dw_hdmi_remove(hdmi->hdmi);
 		return -ENODEV;
 	}
 
-	return component_add(&pdev->dev, &dw_hdmi_imx_ops);
+	ret = component_add(&pdev->dev, &dw_hdmi_imx_ops);
+	if (ret)
+		dw_hdmi_remove(hdmi->hdmi);
+
+	return ret;
 }
 
 static int dw_hdmi_imx_remove(struct platform_device *pdev)
Signature · 1 line
2.25.1
author
#1 lore raw

Hi Philipp,

Quoted 4 lines · Liu Ying

In dw_hdmi_imx_probe(), if error happens after dw_hdmi_probe() returns successfully, dw_hdmi_remove() should be called where necessary as bailout.

Quoted 10 lines
Fixes c805ec7eb210 ("drm/imx: dw_hdmi-imx: move initialization into probe")
Cc Philipp Zabel <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>

Any comments? Can you please pick this up?

Regards,
Liu Ying

Quoted 33 lines
---
 drivers/gpu/drm/imx/dw_hdmi-imx.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/dw_hdmi-imx.c +7 -1
index 87428fb23d9f..a2277a0d6d06 100644
@@ -222,6 +222,7 @@ static int dw_hdmi_imx_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	const struct of_device_id *match = of_match_node(dw_hdmi_imx_dt_ids, np);
 	struct imx_hdmi *hdmi;
+	int ret;
 
 	hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
 	if (!hdmi)
@@ -243,10 +244,15 @@ static int dw_hdmi_imx_probe(struct platform_device *pdev)
 	hdmi->bridge = of_drm_find_bridge(np);
 	if (!hdmi->bridge) {
 		dev_err(hdmi->dev, "Unable to find bridge\n");
+		dw_hdmi_remove(hdmi->hdmi);
 		return -ENODEV;
 	}
 
-	return component_add(&pdev->dev, &dw_hdmi_imx_ops);
+	ret = component_add(&pdev->dev, &dw_hdmi_imx_ops);
+	if (ret)
+		dw_hdmi_remove(hdmi->hdmi);
+
+	return ret;
 }
 
 static int dw_hdmi_imx_remove(struct platform_device *pdev)
#2 lore raw
In reply to Liu Ying
Quoted 45 lines · Liu Ying

In dw_hdmi_imx_probe(), if error happens after dw_hdmi_probe() returns
successfully, dw_hdmi_remove() should be called where necessary as bailout.

Fixes c805ec7eb210 ("drm/imx: dw_hdmi-imx: move initialization into

probe")

Cc Philipp Zabel <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>

---
 drivers/gpu/drm/imx/dw_hdmi-imx.c | 8 +++++++-

 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/dw_hdmi-imx.c +0 -0
index 87428fb23d9f..a2277a0d6d06 100644
@@ -222,6 +222,7 @@ static int dw_hdmi_imx_probe(struct
 platform_device *pdev)
         struct device_node *np = pdev->dev.of_node;

        const struct of_device_id *match = of_match_node(dw_hdmi_imx_dt_ids, np);
        struct imx_hdmi *hdmi;
+       int ret;

        hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL); if (!hdmi)

drivers/gpu/drm/imx/dw_hdmi-imx.c +1 -0
@@ -243,10 +244,15 @@ static int dw_hdmi_imx_probe(struct
 platform_device *pdev)
         hdmi->bridge = of_drm_find_bridge(np);
         if (!hdmi->bridge) {
                 dev_err(hdmi->dev, "Unable to find bridge\n");
+               dw_hdmi_remove(hdmi->hdmi);
                 return -ENODEV;
         }


-       return component_add(&pdev->dev, &dw_hdmi_imx_ops);

Quoted 8 lines

+       ret = component_add(&pdev->dev, &dw_hdmi_imx_ops); +       if (ret)
+               dw_hdmi_remove(hdmi->hdmi);
+
+       return ret;
 }

 static int dw_hdmi_imx_remove(struct platform_device *pdev)

Thank you, applied to imx-drm/fixes.

regards
Philipp