All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Osama Abdelkader" <osama.abdelkader@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 3/4] drm/panel: Use managed helpers in assorted panels
Date: Tue, 15 Sep 2026 15:11:16 +0000	[thread overview]
Message-ID: <20260915151117.180501F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260915145935.60397-4-osama.abdelkader@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] drm/panel: Use-After-Free in panel-dsi-cm due to delayed drm_panel_remove
- [Low] drm/panel: khadas-ts050 compilation error due to undeclared variable
- [Low] drm/panel: tdo-tl070wsh30 compilation error due to undeclared variable
--

commit e1629ed943636f060c6cfc7188b70cdb9700480c
Author: Osama Abdelkader <osama.abdelkader@gmail.com>
Subject: drm/panel: Use managed helpers in assorted panels

This commit converts multiple panel drivers to use managed device helpers
for DRM panels and MIPI DSI attach operations. It removes the corresponding
manual detach and panel remove calls from the driver removal paths.

> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -559,16 +559,17 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	dsi->hs_rate = ddata->panel_data->max_hs_rate;
>  	dsi->lp_rate = ddata->panel_data->max_lp_rate;
>  
> -	drm_panel_add(&ddata->panel);
> +	r = devm_drm_panel_add(dev, &ddata->panel);
> +	if (r)
> +		goto err_sysfs;

[Severity: High]
Does using the managed version of drm_panel_add() here introduce a potential
use-after-free in dsicm_remove()?

By relying on devm, the execution of drm_panel_remove() is deferred to the
devres cleanup phase, which runs after the driver's .remove callback
(dsicm_remove) has already completed.

[ ... ]

> @@ -580,12 +581,13 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  static void dsicm_remove(struct mipi_dsi_device *dsi)
>  {
>  	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
> +	int ret;
>  
>  	dev_dbg(&dsi->dev, "remove\n");
>  
> -	mipi_dsi_detach(dsi);
> -
> -	drm_panel_remove(&ddata->panel);
> +	ret = mipi_dsi_detach(dsi);
> +	if (ret < 0)
> +		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret);
>  
>  	sysfs_remove_group(&dsi->dev.kobj, &dsicm_attr_group);
>  

[Severity: High]
With the manual drm_panel_remove() gone, the panel remains registered with
the DRM core when dsicm_remove() subsequently cleans up the external
backlight reference just below this code block:

    if (ddata->extbldev)
        put_device(&ddata->extbldev->dev);

If a concurrent operation (such as a userspace DRM ioctl triggering a
display modeset) calls dsicm_disable() on the panel during the window
between dsicm_remove() returning and the devres cleanup executing, could
it attempt to use the freed extbldev pointer to disable the backlight?

[ ... ]

> diff --git a/drivers/gpu/drm/panel/panel-khadas-ts050.c b/drivers/gpu/drm/panel/panel-khadas-ts050.c
> --- a/drivers/gpu/drm/panel/panel-khadas-ts050.c
> +++ b/drivers/gpu/drm/panel/panel-khadas-ts050.c
> @@ -825,7 +825,9 @@ static int khadas_ts050_panel_add(struct khadas_ts050_panel *khadas_ts050)
>  	if (err)
>  		return err;
>  
> -	drm_panel_add(&khadas_ts050->base);
> +	ret = devm_drm_panel_add(dev, &khadas_ts050->base);
> +	if (ret)
> +		return ret;

[Severity: Low]
Will this cause a compilation error? It appears the variable "ret" is used
here, but looking at khadas_ts050_panel_add() in the source, only "err"
has been declared in this scope.

[ ... ]

> diff --git a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> --- a/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> +++ b/drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c
> @@ -150,7 +150,9 @@ static int tdo_tl070wsh30_panel_add(struct tdo_tl070wsh30_panel *tdo_tl070wsh30)
>  	if (err)
>  		return err;
>  
> -	drm_panel_add(&tdo_tl070wsh30->base);
> +	ret = devm_drm_panel_add(dev, &tdo_tl070wsh30->base);
> +	if (ret)
> +		return ret;

[Severity: Low]
Does this also fail to compile for the same reason? The variable "ret" is
assigned and checked, but only "err" is declared in tdo_tl070wsh30_panel_add().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260915145935.60397-1-osama.abdelkader@gmail.com?part=3

  reply	other threads:[~2026-09-15 15:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260915145935.60397-1-osama.abdelkader@gmail.com>
2026-09-15 14:59 ` [PATCH v5 1/4] drm/panel: Use devm_mipi_dsi_attach in BOE panels Osama Abdelkader
2026-09-15 14:59 ` [PATCH v5 2/4] drm/panel: Use managed helpers in Novatek and Raydium panels Osama Abdelkader
2026-09-15 14:59 ` [PATCH v5 3/4] drm/panel: Use managed helpers in assorted panels Osama Abdelkader
2026-09-15 15:11   ` sashiko-bot [this message]
2026-09-15 14:59 ` [PATCH v5 4/4] drm/panel: simple: Use managed helpers in panel-simple Osama Abdelkader
2026-09-15 15:08   ` sashiko-bot
2026-09-16  7:50   ` Luca Ceresoli
2026-09-16 17:25     ` Osama Abdelkader

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260915151117.180501F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=osama.abdelkader@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.