[PATCH 00/10] drm/panel: Use refcounted allocation for remaining panel drivers

Albert Esteve posted 10 patches 1 month, 1 week ago
There is a newer version of this series
drivers/gpu/drm/display/drm_dp_helper.c             |  2 +-
drivers/gpu/drm/drm_panel.c                         |  8 ++++----
drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.c  | 10 +++++-----
drivers/gpu/drm/panel/panel-lxd-m9189a.c            | 11 ++++++-----
drivers/gpu/drm/panel/panel-novatek-nt37700f.c      | 11 ++++++-----
drivers/gpu/drm/panel/panel-samsung-s6e63m0.c       | 14 +++++++-------
drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c     | 11 ++++++-----
drivers/gpu/drm/panel/panel-startek-kd070fhfid015.c | 12 ++++++------
drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c        | 14 +++++++-------
drivers/gpu/drm/panel/panel-truly-nt35597.c         | 10 +++++-----
drivers/gpu/drm/panel/panel-visionox-g2647fb105.c   | 13 ++++++-------
include/drm/drm_panel.h                             |  4 ----
12 files changed, 59 insertions(+), 61 deletions(-)
[PATCH 00/10] drm/panel: Use refcounted allocation for remaining panel drivers
Posted by Albert Esteve 1 month, 1 week ago
This series converts 9 remaining panel drivers from the deprecated
devm_kzalloc() + drm_panel_init() pattern to the refcounted
devm_drm_panel_alloc() API. This follows the work by Anusha Srivatsa
who introduced the refcounted panel allocation infrastructure [1] and
converted a first batch of drivers [2] (the last part of a 5 sub-series).

Reasoning:
----------
The old allocation pattern is unsafe: when the panel device is
unbound, devm frees the context struct immediately, but the DRM
device may still hold a reference to the embedded drm_panel through
the panel bridge, leading to a use-after-free. devm_drm_panel_alloc()
wraps the allocation in a kref scheme, so the memory is only freed
when the last reference is dropped.

After this series, there are no remaining callers of drm_panel_init()
under drivers/gpu/drm/panel/, and drm_panel_init() is entirely removed
from the public API.

[1] https://lore.kernel.org/all/20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@redhat.com/
[2] https://lore.kernel.org/all/20250710-b4-driver-convert-last-part-july-v1-0-de73ba81b2f5@redhat.com/

Signed-off-by: Albert Esteve <aesteve@redhat.com>
---
Albert Esteve (10):
      drm/panel/visionox-g2647fb105: Use refcounted allocation in place of devm_kzalloc()
      drm/panel/samsung-s6e63m0: Use refcounted allocation in place of devm_kzalloc()
      drm/panel/novatek-nt37700f: Use refcounted allocation in place of devm_kzalloc()
      drm/panel/lxd-m9189a: Use refcounted allocation in place of devm_kzalloc()
      drm/panel/ilitek-ili9806e: Use refcounted allocation in place of devm_kzalloc()
      drm/panel/tdo-tl070wsh30: Use refcounted allocation in place of devm_kzalloc()
      drm/panel/sharp-ls043t1le01: Use refcounted allocation in place of devm_kzalloc()
      drm/panel/truly-nt35597: Use refcounted allocation in place of devm_kzalloc()
      drm/panel/startek-kd070fhfid015: Use refcounted allocation in place of devm_kzalloc()
      drm/panel: Make drm_panel_init() static

 drivers/gpu/drm/display/drm_dp_helper.c             |  2 +-
 drivers/gpu/drm/drm_panel.c                         |  8 ++++----
 drivers/gpu/drm/panel/panel-ilitek-ili9806e-core.c  | 10 +++++-----
 drivers/gpu/drm/panel/panel-lxd-m9189a.c            | 11 ++++++-----
 drivers/gpu/drm/panel/panel-novatek-nt37700f.c      | 11 ++++++-----
 drivers/gpu/drm/panel/panel-samsung-s6e63m0.c       | 14 +++++++-------
 drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c     | 11 ++++++-----
 drivers/gpu/drm/panel/panel-startek-kd070fhfid015.c | 12 ++++++------
 drivers/gpu/drm/panel/panel-tdo-tl070wsh30.c        | 14 +++++++-------
 drivers/gpu/drm/panel/panel-truly-nt35597.c         | 10 +++++-----
 drivers/gpu/drm/panel/panel-visionox-g2647fb105.c   | 13 ++++++-------
 include/drm/drm_panel.h                             |  4 ----
 12 files changed, 59 insertions(+), 61 deletions(-)
---
base-commit: 74fe02ce122a6103f207d29fafc8b3a53de6abaf
change-id: 20260506-drm_panel_init_rm-3a4489701f10

Best regards,
-- 
Albert Esteve <aesteve@redhat.com>
Re: [PATCH 00/10] drm/panel: Use refcounted allocation for remaining panel drivers
Posted by Maxime Ripard 1 month ago
Hi,

On Thu, May 07, 2026 at 01:52:58PM +0200, Albert Esteve wrote:
> This series converts 9 remaining panel drivers from the deprecated
> devm_kzalloc() + drm_panel_init() pattern to the refcounted
> devm_drm_panel_alloc() API. This follows the work by Anusha Srivatsa
> who introduced the refcounted panel allocation infrastructure [1] and
> converted a first batch of drivers [2] (the last part of a 5 sub-series).
> 
> Reasoning:
> ----------
> The old allocation pattern is unsafe: when the panel device is
> unbound, devm frees the context struct immediately, but the DRM
> device may still hold a reference to the embedded drm_panel through
> the panel bridge, leading to a use-after-free. devm_drm_panel_alloc()
> wraps the allocation in a kref scheme, so the memory is only freed
> when the last reference is dropped.
> 
> After this series, there are no remaining callers of drm_panel_init()
> under drivers/gpu/drm/panel/, and drm_panel_init() is entirely removed
> from the public API.
> 
> [1] https://lore.kernel.org/all/20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@redhat.com/
> [2] https://lore.kernel.org/all/20250710-b4-driver-convert-last-part-july-v1-0-de73ba81b2f5@redhat.com/
> 
> Signed-off-by: Albert Esteve <aesteve@redhat.com>

Aside from the minor comment on the doc in patch 10,
Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime