aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJulien Isorce <[email protected]>2015-11-05 08:24:45 +0000
committerEmil Velikov <[email protected]>2015-11-05 23:39:45 +0000
commit497bde6727260e7719c680dc483b10c0751a3fcd (patch)
tree28daef0c820730dd3cc468ca5403787072dd7a2c /src/gallium
parente0b896c86c92c4dd02aea7fb5eb8eabe089b9e58 (diff)
st/va: fix memory leak on error in vlVaCreateSurfaces2
Found by coverity: CID #1337953 Signed-off-by: Julien Isorce <[email protected]> Reviewed-by: Christian König <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/va/surface.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index 59815aa4c5a..3db21c3de39 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -479,8 +479,10 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
util_dynarray_init(&surface->subpics);
surfaces[index] = handle_table_add(drv->htab, surface);
- if (!surfaces[index])
+ if (!surfaces[index]) {
+ surface->buffer->destroy(surface->buffer);
return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
return VA_STATUS_SUCCESS;
}
@@ -612,15 +614,19 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
switch (memory_type) {
case VA_SURFACE_ATTRIB_MEM_TYPE_VA:
surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat);
- if (!surf->buffer)
+ if (!surf->buffer) {
+ FREE(surf);
goto no_res;
+ }
util_dynarray_init(&surf->subpics);
surfaces[i] = handle_table_add(drv->htab, surf);
break;
case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME:
vaStatus = suface_from_external_memory(ctx, surf, memory_attibute, i, surfaces, &templat);
- if (vaStatus != VA_STATUS_SUCCESS)
+ if (vaStatus != VA_STATUS_SUCCESS) {
+ FREE(surf);
goto no_res;
+ }
break;
default:
assert(0);