[PATCH v2 01/16] drm/panel: get/put panel reference in drm_panel_add/remove()

Anusha Srivatsa asrivats at redhat.com
Fri Jun 20 20:47:25 UTC 2025


On Fri, Jun 20, 2025 at 4:11 AM Maxime Ripard <mripard at kernel.org> wrote:

> On Fri, Jun 20, 2025 at 10:33:53AM +0200, Luca Ceresoli wrote:
> > Hello Anusha,
> >
> > On Thu, 19 Jun 2025 14:15:53 -0500
> > Anusha Srivatsa <asrivats at redhat.com> wrote:
> >
> > > Take the panel reference and put it back as required.
> > > drm_panel_add() and drm_panel_remove() add a panel to
> > > the global registry and removes a panel respectively.
> > > Use get() and put() helpers to keep up with refcounting.
> > >
> > > Reviewed-by: Luca Ceresoli <luca.ceresoli at bootlin.com>
> > > Signed-off-by: Anusha Srivatsa <asrivats at redhat.com>
> >
> > This patch is good.
> >
> > I'd just point out that this must be applied only after all drivers
> > have been converted to the the _alloc API, otherwise with the following
> > sequence:
> >
> >   panel = devm_kzalloc();
> >   drm_panel_init(panel);
> >   drm_panel_add(panel);
> >   ...
> >   drm_panel_remove(panel); <-----
> >
> > at the drm_panel_remove() you'd have a warning:
> >
> >   refcount_t: addition on 0; use-after-free.
>
> Yes, Luca. makes sense. Thanks.
You had reviewed this patch already, but thanks :)

> So, if all panel drivers are converted:
>
> Not all panels are yet:
> $ rg -l drm_panel_init -- drivers/gpu/drm/panel/ | wc -l
> 20
>
^^^^^
 Yup. Looks like there are some more occurences. On it.

Anusha

> Maxime
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20250620/334d90ec/attachment.htm>


More information about the dri-devel mailing list