Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] Memory leak of the `formats` array on the encoder allocation error 
path.
--

commit ca651199ad906493630752bf01737d3dca9cebbd
Author: Dmitry Baryshkov <[email protected]>
drm/mali: use drmm_writeback_connector_init()

This commit transitions the mali driver to use the managed
drmm_writeback_connector_init() function to ensure proper job queue
cleanup. It also allocates the virtual encoder using the managed
drmm_plain_encoder_alloc() helper.

> diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c
> --- a/drivers/gpu/drm/arm/malidp_mw.c
> +++ b/drivers/gpu/drm/arm/malidp_mw.c

[ ... ]

> @@ -224,11 +219,19 @@ int malidp_mw_connector_init(struct drm_device *drm)
>       if (!formats)
>               return -ENOMEM;
>  
> -     ret = drm_writeback_connector_init(drm, &malidp->mw_connector,
> -                                        &malidp_mw_connector_funcs,
> -                                        &malidp_mw_encoder_helper_funcs,
> -                                        formats, n_formats,
> -                                        1 << drm_crtc_index(&malidp->crtc));
> +     encoder = drmm_plain_encoder_alloc(drm, NULL, DRM_MODE_ENCODER_VIRTUAL,
> +                                        NULL);
> +     if (IS_ERR(encoder))
> +             return PTR_ERR(encoder);

[Severity: Medium]
The formats array is allocated earlier in this function via
get_writeback_formats(), but it does not appear to be freed on this
error path. Does this code leak the formats array if
drmm_plain_encoder_alloc() fails?

> +
> +     drm_encoder_helper_add(encoder, &malidp_mw_encoder_helper_funcs);
> +
> +     encoder->possible_crtcs = drm_crtc_mask(&malidp->crtc);
> +
> +     ret = drmm_writeback_connector_init(drm, &malidp->mw_connector,
> +                                         &malidp_mw_connector_funcs,
> +                                         encoder,
> +                                         formats, n_formats);
>       kfree(formats);
>       if (ret)
>               return ret;

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=5

Reply via email to