st/va: release held locks in error paths
authorGrazvydas Ignotas <notasas@gmail.com>
Mon, 15 Jan 2018 21:59:20 +0000 (23:59 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Tue, 16 Jan 2018 22:39:55 +0000 (00:39 +0200)
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
src/gallium/state_trackers/va/config.c
src/gallium/state_trackers/va/image.c
src/gallium/state_trackers/va/picture.c

index 25043d63742c23e513a0c2ec8788ffcb5f7e3414..7bc031a1a2f2f711b91a9663256c3fd54513853a 100644 (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);
index 86ae8685802ef3d71bc6eaaa0a1d7a6d07ff3f5f..3f892c9842cc793afc7bf89bfc1ebc5e8b72021e 100644 (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,
index 23a4b524d7ba9ead7ea4be89a5d2d32b36691932..22934e43ccd05efff28c40a32276caf2e68bc7ac 100644 (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);