drm/panel: Delete panel on mipi_dsi_attach() failure
authorBrian Norris <briannorris@chromium.org>
Fri, 24 Sep 2021 00:33:55 +0000 (17:33 -0700)
committerSam Ravnborg <sam@ravnborg.org>
Thu, 14 Oct 2021 19:55:12 +0000 (21:55 +0200)
Many DSI panel drivers fail to clean up their panel references on
mipi_dsi_attach() failure, so we're leaving a dangling drm_panel
reference to freed memory. Clean that up on failure.

Noticed by inspection, after seeing similar problems on other drivers.
Therefore, I'm not marking Fixes/stable.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210923173336.3.If9e74fa9b1d6eaa9e0e5b95b2b957b992740251c@changeid
drivers/gpu/drm/panel/panel-feiyang-fy07024di26a30d.c
drivers/gpu/drm/panel/panel-jdi-lt070me05000.c
drivers/gpu/drm/panel/panel-novatek-nt36672a.c
drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c
drivers/gpu/drm/panel/panel-ronbo-rb070d30.c
drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams452ef01.c
drivers/gpu/drm/panel/panel-samsung-sofef00.c
drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c

index 581661b506f813d38ff1bb6de68316b129c8d6fa..f9c1f7bc8218c88b69590d7aaa90342dd7498fb8 100644 (file)
@@ -227,7 +227,13 @@ static int feiyang_dsi_probe(struct mipi_dsi_device *dsi)
        dsi->format = MIPI_DSI_FMT_RGB888;
        dsi->lanes = 4;
 
-       return mipi_dsi_attach(dsi);
+       ret = mipi_dsi_attach(dsi);
+       if (ret < 0) {
+               drm_panel_remove(&ctx->panel);
+               return ret;
+       }
+
+       return 0;
 }
 
 static int feiyang_dsi_remove(struct mipi_dsi_device *dsi)
index 733010b5e4f536316a59e7200793b620224613de..3c86ad262d5e013a5285f7feec302a2580f5cfba 100644 (file)
@@ -473,7 +473,13 @@ static int jdi_panel_probe(struct mipi_dsi_device *dsi)
        if (ret < 0)
                return ret;
 
-       return mipi_dsi_attach(dsi);
+       ret = mipi_dsi_attach(dsi);
+       if (ret < 0) {
+               jdi_panel_del(jdi);
+               return ret;
+       }
+
+       return 0;
 }
 
 static int jdi_panel_remove(struct mipi_dsi_device *dsi)
index 533cd3934b8b7f348cdc08b3e4890555ed5930e9..839b263fb3c0f075af106febe7834a42efd4039e 100644 (file)
@@ -656,7 +656,13 @@ static int nt36672a_panel_probe(struct mipi_dsi_device *dsi)
        if (err < 0)
                return err;
 
-       return mipi_dsi_attach(dsi);
+       err = mipi_dsi_attach(dsi);
+       if (err < 0) {
+               drm_panel_remove(&pinfo->base);
+               return err;
+       }
+
+       return 0;
 }
 
 static int nt36672a_panel_remove(struct mipi_dsi_device *dsi)
index 3c20beeb17819dc024e9ab3ca1239acfe102ba17..3991f5d950af49eb11702e39143fbde8b4f9fba9 100644 (file)
@@ -241,7 +241,13 @@ static int wuxga_nt_panel_probe(struct mipi_dsi_device *dsi)
        if (ret < 0)
                return ret;
 
-       return mipi_dsi_attach(dsi);
+       ret = mipi_dsi_attach(dsi);
+       if (ret < 0) {
+               wuxga_nt_panel_del(wuxga_nt);
+               return ret;
+       }
+
+       return 0;
 }
 
 static int wuxga_nt_panel_remove(struct mipi_dsi_device *dsi)
index a3782830ae3c4ba0882dce04c3d4cc491f8add92..1fb579a574d9f52ccd484db2010e91da44cdbd3c 100644 (file)
@@ -199,7 +199,13 @@ static int rb070d30_panel_dsi_probe(struct mipi_dsi_device *dsi)
        dsi->format = MIPI_DSI_FMT_RGB888;
        dsi->lanes = 4;
 
-       return mipi_dsi_attach(dsi);
+       ret = mipi_dsi_attach(dsi);
+       if (ret < 0) {
+               drm_panel_remove(&ctx->panel);
+               return ret;
+       }
+
+       return 0;
 }
 
 static int rb070d30_panel_dsi_remove(struct mipi_dsi_device *dsi)
index ea63799ff2a1e427fc872282e97f573e5e97ec5d..29fde3823212bf8715d7876c4eb781fb2ae02217 100644 (file)
@@ -247,6 +247,7 @@ static int s6e88a0_ams452ef01_probe(struct mipi_dsi_device *dsi)
        ret = mipi_dsi_attach(dsi);
        if (ret < 0) {
                dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
+               drm_panel_remove(&ctx->panel);
                return ret;
        }
 
index 8cb1853574bb819f0d3fa0bc41d809b68215f1e3..6d107e14fcc559361e3c272c5f52d98dede96ba7 100644 (file)
@@ -302,6 +302,7 @@ static int sofef00_panel_probe(struct mipi_dsi_device *dsi)
        ret = mipi_dsi_attach(dsi);
        if (ret < 0) {
                dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
+               drm_panel_remove(&ctx->panel);
                return ret;
        }
 
index b937e24dac8e0e00f13362dd725e9ea5136fbdf8..25829a0a8e80129f538d9a3417d7a0ca51630e3e 100644 (file)
@@ -296,7 +296,13 @@ static int sharp_nt_panel_probe(struct mipi_dsi_device *dsi)
        if (ret < 0)
                return ret;
 
-       return mipi_dsi_attach(dsi);
+       ret = mipi_dsi_attach(dsi);
+       if (ret < 0) {
+               sharp_nt_panel_del(sharp_nt);
+               return ret;
+       }
+
+       return 0;
 }
 
 static int sharp_nt_panel_remove(struct mipi_dsi_device *dsi)