Skip to content

Commit

Permalink
drm/panel: Delete panel on mipi_dsi_attach() failure
Browse files Browse the repository at this point in the history
[ Upstream commit 9bf7123 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
computersforpeace authored and gregkh committed Jan 27, 2022
1 parent 493c7d5 commit 5734736
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 6 deletions.
8 changes: 7 additions & 1 deletion drivers/gpu/drm/panel/panel-feiyang-fy07024di26a30d.c
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion drivers/gpu/drm/panel/panel-jdi-lt070me05000.c
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion drivers/gpu/drm/panel/panel-novatek-nt36672a.c
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion drivers/gpu/drm/panel/panel-ronbo-rb070d30.c
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams452ef01.c
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/panel/panel-samsung-sofef00.c
Expand Up @@ -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;
}

Expand Down
8 changes: 7 additions & 1 deletion drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c
Expand Up @@ -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)
Expand Down

0 comments on commit 5734736

Please sign in to comment.