[PATCH xf86-video-amdgpu] Free previous xf86CrtcRec gamma LUT memory

Alex Deucher alexdeucher at gmail.com
Thu Jul 19 19:53:10 UTC 2018


On Thu, Jul 19, 2018 at 5:37 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> We were leaking it.
>
> Also, don't bother allocating new memory if it's already the expected
> size.
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  src/drmmode_display.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
> index 1aefd199b..e947ca979 100644
> --- a/src/drmmode_display.c
> +++ b/src/drmmode_display.c
> @@ -3629,13 +3629,18 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
>
>                         for (i = 0; i < xf86_config->num_crtc; i++) {
>                                 xf86CrtcPtr crtc = xf86_config->crtc[i];
> -                               void *gamma = malloc(1024 * 3 * sizeof(CARD16));
> +                               void *gamma;
>
> +                               if (crtc->gamma_size == 1024)
> +                                       continue;
> +
> +                               gamma = malloc(1024 * 3 * sizeof(CARD16));
>                                 if (!gamma) {
>                                         ErrorF("Failed to allocate gamma LUT memory\n");
>                                         return FALSE;
>                                 }
>
> +                               free(crtc->gamma_red);
>                                 crtc->gamma_size = 1024;
>                                 crtc->gamma_red = gamma;
>                                 crtc->gamma_green = crtc->gamma_red + crtc->gamma_size;
> --
> 2.18.0
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list