[Libva] [PATCH] CreateSurfaces2: forward function return to caller

Xu, Guangxin guangxin.xu at intel.com
Tue Jun 30 18:40:06 PDT 2015


Sorry, this patch may leak current obj_surface. I will send new one.

> -----Original Message-----
> From: Xu, Guangxin
> Sent: Tuesday, June 30, 2015 3:22 PM
> To: libva at lists.freedesktop.org
> Cc: Xu, Guangxin
> Subject: [PATCH] CreateSurfaces2: forward function return to caller
> 
> we did not check following function's return:
> i965_surface_native_memory
> i965_suface_external_memory
> i965_check_alloc_surface_bo
> It will be in trouble if underlay buffer allocation is failed.
> ---
>  src/i965_drv_video.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index cfaab32..b14acf8
> 100644
> --- a/src/i965_drv_video.c
> +++ b/src/i965_drv_video.c
> @@ -989,9 +989,7 @@ i965_surface_native_memory(VADriverContextP ctx,
>          expected_fourcc == VA_FOURCC_YV16)
>          tiling = 0;
> 
> -    i965_check_alloc_surface_bo(ctx, obj_surface, tiling, expected_fourcc,
> get_sampling_from_fourcc(expected_fourcc));
> -
> -    return VA_STATUS_SUCCESS;
> +    return i965_check_alloc_surface_bo(ctx, obj_surface, tiling,
> + expected_fourcc, get_sampling_from_fourcc(expected_fourcc));
>  }
> 
>  static VAStatus
> @@ -1327,21 +1325,23 @@ i965_CreateSurfaces2(
>                      }
>                  }
>              }
> -            i965_surface_native_memory(ctx,
> -                                       obj_surface,
> -                                       format,
> -                                       expected_fourcc);
> +            vaStatus = i965_surface_native_memory(ctx,
> +                                                  obj_surface,
> +                                                  format,
> +
> expected_fourcc);
>              break;
> 
>          case I965_SURFACE_MEM_GEM_FLINK:
>          case I965_SURFACE_MEM_DRM_PRIME:
> -            i965_suface_external_memory(ctx,
> -                                        obj_surface,
> -                                        memory_type,
> -                                        memory_attibute,
> -                                        i);
> +            vaStatus = i965_suface_external_memory(ctx,
> +                                                   obj_surface,
> +                                                   memory_type,
> +
> memory_attibute,
> +                                                   i);
>              break;
>          }
> +        if (VA_STATUS_SUCCESS != vaStatus)
> +            break;
>      }
> 
>      /* Error recovery */
> --
> 1.9.1



More information about the Libva mailing list