Re: [PATCH 1/5] drm/panel: Add new helpers for refcounted panel allocatons

From: Luca Ceresoli
Date: Wed Mar 26 2025 - 05:23:53 EST


Hello Anusha,

On Tue, 25 Mar 2025 13:24:08 -0400
Anusha Srivatsa <asrivats@xxxxxxxxxx> wrote:

> Introduce reference counted allocations for panels to avoid
> use-after-free. The patch adds the macro devm_drm_bridge_alloc()
> to allocate a new refcounted panel. Followed the documentation for
> drmm_encoder_alloc() and devm_drm_dev_alloc and other similar
> implementations for this purpose.
>
> Signed-off-by: Anusha Srivatsa <asrivats@xxxxxxxxxx>

[...]

> +void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t offset,
> + const struct drm_panel_funcs *funcs,
> + int connector_type);
> +
> +/**
> + * devm_drm_panel_alloc - Allocate and initialize an refcounted panel
^^
"a refcounted panel"

> + * @dev: struct device of the panel device
> + * @type: the type of the struct which contains struct &drm_panel
> + * @member: the name of the &drm_panel within @type
> + * @funcs: callbacks for this panel
> + * @connector_type: connector type of the driver

I'd say it's the connector type in the hardware, rather than of the
driver (the driver follows what is in the hardware. Maybe you can just
copy the description present in the drm_panel_init kdoc:

* @connector_type: the connector type (DRM_MODE_CONNECTOR_*) corresponding to
* the panel interface (must NOT be DRM_MODE_CONNECTOR_Unknown)

Other than that it looks good!

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com