Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/sti: leak of managed pixmap DMA buffer on error in
  sti_cursor_create()
--

commit e56d841601d0e4ed868b107dc1847844ca728b69
Author: Minseo Park <[email protected]>

drm/sti: cursor: do not resize the pixmap from .atomic_check()

This commit allocates the cursor pixmap DMA buffer once at plane creation
time instead of reallocating it inside sti_cursor_atomic_check().

> diff --git a/drivers/gpu/drm/sti/sti_cursor.c 
> b/drivers/gpu/drm/sti/sti_cursor.c
> index 66f56355309f9..7295b6edb8ef9 100644
> --- a/drivers/gpu/drm/sti/sti_cursor.c
> +++ b/drivers/gpu/drm/sti/sti_cursor.c
[ ... ]
> @@ -377,6 +353,22 @@ struct drm_plane *sti_cursor_create(struct drm_device 
> *drm_dev,
>               return NULL;
>       }
>  
> +     /*
> +      * Allocate the pixmap once, for the largest cursor the hardware
> +      * supports.  It used to be reallocated from .atomic_check(), which
> +      * freed a buffer the display engine could still be scanning out.
> +      * Use the managed helper so it is released with the device.
> +      */
> +     cursor->pixmap.size = STI_CURS_MAX_SIZE * STI_CURS_MAX_SIZE;
> +     cursor->pixmap.base = dmam_alloc_attrs(dev, cursor->pixmap.size,
> +                                            &cursor->pixmap.paddr,
> +                                            GFP_KERNEL,
> +                                            DMA_ATTR_WRITE_COMBINE);
> +     if (!cursor->pixmap.base) {
> +             drm_err(drm_dev, "Failed to allocate memory for pixmap\n");
> +             goto err_clut;
> +     }
> +
>       /* Allocate clut buffer */
>       size = 0x100 * sizeof(unsigned short);
>       cursor->clut = dma_alloc_wc(dev, size, &cursor->clut_paddr,
> @@ -387,7 +379,6 @@ struct drm_plane *sti_cursor_create(struct drm_device 
> *drm_dev,
>               goto err_clut;
>       }
>  
> -     cursor->dev = dev;
>       cursor->regs = baseaddr;
>       cursor->plane.desc = desc;
>       cursor->plane.status = STI_PLANE_DISABLED;

[Severity: Medium]
Does sti_cursor_create() leak cursor->pixmap.base when allocating
cursor->clut or calling drm_universal_plane_init() fails?

The err_plane and err_clut paths free cursor->clut and cursor, without
releasing cursor->pixmap.base.  Because sti_compositor_bind() treats a
NULL return from sti_cursor_create() as non-fatal and still returns 0,
devres on compo->dev is not released on failure and the 16 KiB DMA buffer
stays allocated while the compositor remains bound.

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

Reply via email to