Commit 9bf7123b authored by Brian Norris's avatar Brian Norris Committed by Sam Ravnborg

drm/panel: Delete panel on mipi_dsi_attach() failure

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: default avatarBrian Norris <briannorris@chromium.org>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210923173336.3.If9e74fa9b1d6eaa9e0e5b95b2b957b992740251c@changeid
parent 32a267e9
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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)
......
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