Re: [PATCH v3 5/6] drm/panel: Use devm_mipi_dsi_attach in display vendor panels

[email protected]
Newsgroups org.freedesktop.lists.dri-devel
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing `drm_panel_remove()` on DSI attach failure leaves a dangling pointer in the global panel list.
--

--- Patch [5]: [PATCH v3 5/6] drm/panel: Use devm_mipi_dsi_attach in display vendor panels ---
commit 861964400906b56ec8ecf322e4a2fb68f45fa468
Author: Osama Abdelkader <[email protected]>

drm/panel: Use devm_mipi_dsi_attach in display vendor panels

This patch converts several MIPI DSI panel drivers to use the managed
devm_mipi_dsi_attach() helper and removes the manual detach calls from
their respective remove functions.

> diff --git a/drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c b/drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c
> --- a/drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c
> +++ b/drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c
> @@ -202,7 +202,7 @@ static int jdi_fhd_r63452_probe(struct mipi_dsi_device *dsi)
>  
>  	drm_panel_add(&ctx->panel);
>  
> -	ret = mipi_dsi_attach(dsi);
> +	ret = devm_mipi_dsi_attach(&dsi->dev, dsi);
>  	if (ret < 0) {
>  		dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
>  		return ret;

[Severity: High]
This isn't a bug introduced by this patch, but shouldn't we call
drm_panel_remove() before returning here?

Since the panel context is allocated using devm_drm_panel_alloc() earlier in
jdi_fhd_r63452_probe(), returning an error will cause devres to automatically
free the memory.

Because drm_panel_add() was called right before the attach attempt, will this
leave a dangling pointer in the global panel_list? It looks like this could
result in a use-after-free or list corruption the next time the list is
traversed.

Several of the other panel drivers updated in this patch (such as
ltk050h3146w) correctly call drm_panel_remove() in this error path.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.