Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] Missing `kfree(gma_crtc)` in the error handling path for 
`drm_crtc_init_with_planes()` causes a memory leak.
--

commit 3a480bbcb082382b05d96a88db66494d625ba890
Author: Shixiong Ou <[email protected]>

drm/gma500: Create the primary plane in the driver

This commit replaces drm_crtc_init() with a driver-owned primary plane
that advertises only XRGB8888, preventing a warning about unsupported
per-pixel alpha formats.

> diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c 
> b/drivers/gpu/drm/gma500/psb_intel_display.c
> --- a/drivers/gpu/drm/gma500/psb_intel_display.c
> +++ b/drivers/gpu/drm/gma500/psb_intel_display.c

[ ... ]

> @@ -494,7 +510,27 @@ void psb_intel_crtc_init(struct drm_device *dev, int 
> pipe,
>               return;
>       }
>  
> -     drm_crtc_init(dev, &gma_crtc->base, &gma_crtc_funcs);
> +     primary = __drm_universal_plane_alloc(dev, sizeof(*primary), 0, 0,
> +                                           &gma_primary_plane_funcs,
> +                                           gma_primary_formats,
> +                                           ARRAY_SIZE(gma_primary_formats),
> +                                           NULL, DRM_PLANE_TYPE_PRIMARY, 
> NULL);
> +     if (IS_ERR(primary)) {
> +             dev_err(dev->dev, "Failed to allocate primary plane: %pe\n",
> +                     primary);
> +             kfree(gma_crtc->crtc_state);
> +             kfree(gma_crtc);
> +             return;
> +     }
> +
> +     if (drm_crtc_init_with_planes(dev, &gma_crtc->base, primary, NULL,
> +                                   &gma_crtc_funcs, NULL)) {
> +             dev_err(dev->dev, "Failed to init CRTC %d\n", pipe);
> +             drm_plane_cleanup(primary);
> +             kfree(primary);
> +             kfree(gma_crtc->crtc_state);

[Severity: Medium]
Does this error path leak the gma_crtc structure?

The gma_crtc structure is allocated via kzalloc() at the beginning of
psb_intel_crtc_init(). While the primary plane allocation error path
above correctly cleans it up, this error path appears to be missing a
kfree(gma_crtc) before returning.

> +             return;
> +     }

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

Reply via email to