On Tue, May 26, 2026 at 12:46:30PM -0600, Alex Hung wrote:
> Will allocating wbcon with drmm_kzalloc before calling
> amdgpu_dm_wb_connector_init be more memory-safe as below?

Sorry, it took me a while. Yes, it seems to be a correct idea. I'll
implement it slightly differently.

> 
> 
> @@ -5790,7 +5791,8 @@ static int amdgpu_dm_initialize_drm_device(struct
> amdgpu_device *adev)
>               link = dc_get_link_at_index(dm->dc, i);
> 
>               if (link->connector_signal == SIGNAL_TYPE_VIRTUAL) {
> -                     struct amdgpu_dm_wb_connector *wbcon = 
> kzalloc_obj(*wbcon);
> +                     struct amdgpu_dm_wb_connector *wbcon =
> +                             drmm_kzalloc(adev_to_drm(adev), sizeof(*wbcon), 
> GFP_KERNEL);
> 
>                       if (!wbcon) {
>                               drm_err(adev_to_drm(adev), "KMS: Failed to 
> allocate writeback
> connector\n");
> @@ -5799,7 +5801,6 @@ static int amdgpu_dm_initialize_drm_device(struct
> amdgpu_device *adev)
> 
>                       if (amdgpu_dm_wb_connector_init(dm, wbcon, i)) {
>                               drm_err(adev_to_drm(adev), "KMS: Failed to 
> initialize writeback
> connector\n");
> -                             kfree(wbcon);
>                               continue;
>                       }
> 
> On 5/4/26 18:24, Dmitry Baryshkov wrote:
> > The driver uses drm_writeback_connector_init() instead of its drmm
> > counterpart, but it doesn't perform the job queue cleanup (neither
> > manually nor by calling drm_writeback_connector_cleanup()). On the
> > contrary, the drmm_writeback_connector_init() function ensures the
> > proper cleanup of the job queue.
> > 
> > Use drmm_plain_encoder_alloc() to allocate simple encoder and
> > drmm_writeback_connector_init() in order to initialize writeback
> > connector instance.
> > 
> > Reviewed-by: Louis Chauvet <[email protected]>
> > Reviewed-by: Suraj Kandpal <[email protected]>
> > Signed-off-by: Dmitry Baryshkov <[email protected]>
> > ---
> >   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    |  2 +-
> >   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c | 18 
> > +++++++++++++-----
> >   2 files changed, 14 insertions(+), 6 deletions(-)

-- 
With best wishes
Dmitry

Reply via email to