From 0ad73031ec2f9dee6d3ad20dd625b0134ea8ec8b Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Mon, 15 Jan 2018 23:59:20 +0200 Subject: st/va: release held locks in error paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found with the help of following Coccinelle semantic patch: // @@ expression E; @@ \(pthread_mutex_lock\|mtx_lock\|simple_mtx_lock\)(E) ... ( \(pthread_mutex_unlock\|mtx_unlock\|simple_mtx_unlock\)(E); ... return ...; | + maybe need_unlock(E); return ...; ) // Signed-off-by: Grazvydas Ignotas Reviewed-by: Christian König Cc: mesa-stable@lists.freedesktop.org --- src/gallium/state_trackers/va/config.c | 4 +++- src/gallium/state_trackers/va/image.c | 4 +++- src/gallium/state_trackers/va/picture.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/gallium/state_trackers') diff --git a/src/gallium/state_trackers/va/config.c b/src/gallium/state_trackers/va/config.c index 25043d63742..7bc031a1a2f 100644 --- a/src/gallium/state_trackers/va/config.c +++ b/src/gallium/state_trackers/va/config.c @@ -308,8 +308,10 @@ vlVaDestroyConfig(VADriverContextP ctx, VAConfigID config_id) mtx_lock(&drv->mutex); config = handle_table_get(drv->htab, config_id); - if (!config) + if (!config) { + mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_INVALID_CONFIG; + } FREE(config); handle_table_remove(drv->htab, config_id); diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 86ae8685802..3f892c9842c 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -548,8 +548,10 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &dst_box, &transfer); - if (map == NULL) + if (map == NULL) { + mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_OPERATION_FAILED; + } u_copy_nv12_from_yv12((const void * const*) data, pitches, i, j, transfer->stride, tex->array_size, diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 23a4b524d7b..22934e43ccd 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -682,9 +682,11 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) vl_compositor_yuv_deint_full(&drv->cstate, &drv->compositor, old_buf, surf->buffer, &src_rect, &dst_rect, VL_COMPOSITOR_WEAVE); - } else + } else { /* Can't convert from progressive to interlaced yet */ + mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_INVALID_SURFACE; + } } old_buf->destroy(old_buf); -- cgit v1.2.3