[Mesa-dev] [PATCH] gbm-dri: Duplicate image after checking its format.

Eric Engestrom eric.engestrom at imgtec.com
Mon Jan 23 12:17:57 UTC 2017


On Wednesday, 2016-12-21 10:55:28 +0100, mateuszx.potrola at intel.com wrote:
> From: Mateusz Polrola <mateuszx.potrola at intel.com>
> 
> If image will be duplicated before checking if its format is supported
> it may leak memory, as duplicated image for non supported formats is
> not being destroyed.
> 
> Signed-off-by: Mateusz Polrola <mateuszx.potrola at intel.com>

You are correct, so this patch is:
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

However, when I looked at the code, it looks like a lot more places leak `image`.
I'll send another patch in a minute (to be applied on top of yours).

Cheers,
  Eric

> ---
>  src/gbm/backends/dri/gbm_dri.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
> index 45cb42a..941d915 100644
> --- a/src/gbm/backends/dri/gbm_dri.c
> +++ b/src/gbm/backends/dri/gbm_dri.c
> @@ -679,8 +679,6 @@ gbm_dri_bo_import(struct gbm_device *gbm,
>           return NULL;
>        }
>  
> -      image = dri->image->dupImage(wb->driver_buffer, NULL);
> -
>        switch (wb->format) {
>        case WL_DRM_FORMAT_XRGB8888:
>           gbm_format = GBM_FORMAT_XRGB8888;
> @@ -697,6 +695,8 @@ gbm_dri_bo_import(struct gbm_device *gbm,
>        default:
>           return NULL;
>        }
> +
> +      image = dri->image->dupImage(wb->driver_buffer, NULL);
>        break;
>     }
>  #endif
> -- 
> 2.5.5
> 
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de
> Managing Directors: Christin Eisenschmid, Christian Lamprechter
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
> 


More information about the mesa-dev mailing list