block: fix qcow2_co_flush deadlock
authorDong Xu Wang <wdongxu@linux.vnet.ibm.com>
Thu, 27 Oct 2011 09:22:28 +0000 (17:22 +0800)
committerKevin Wolf <kwolf@redhat.com>
Fri, 28 Oct 2011 17:25:49 +0000 (19:25 +0200)
If qcow2_cache_flush failed, s->lock will not be unlock.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2.c

index a181932b67a6aa36d0acd51e81774e318cebd49b..ef057d31e05127a4c9c1dd934fe731970e12d14b 100644 (file)
@@ -1113,11 +1113,13 @@ static int qcow2_co_flush(BlockDriverState *bs)
     qemu_co_mutex_lock(&s->lock);
     ret = qcow2_cache_flush(bs, s->l2_table_cache);
     if (ret < 0) {
+        qemu_co_mutex_unlock(&s->lock);
         return ret;
     }
 
     ret = qcow2_cache_flush(bs, s->refcount_block_cache);
     if (ret < 0) {
+        qemu_co_mutex_unlock(&s->lock);
         return ret;
     }
     qemu_co_mutex_unlock(&s->lock);