st/va: release held locks in error paths

Found with the help of following Coccinelle semantic patch:
// <smpl>
@@
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 ...;
)
// </smpl>

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Cc: mesa-stable@lists.freedesktop.org
This commit is contained in:
Grazvydas Ignotas 2018-01-15 23:59:20 +02:00
parent cce982a70b
commit 0ad73031ec
3 changed files with 9 additions and 3 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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);