Skip to contentSkip to conversation

qcow: fix a reference leak

PATCH Applied KONRAD Frederic 2 participants 2 messages Jul 25, 2018 – Jul 26, 2018 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qcow: fix a reference leak

Since 42a3e1ab367cdf38cce093de24eb406b99a4ef96 qemu asserts when using the vvfat driver:

git clone git://qemu.org/qemu.git
cd qemu
./configure --target-list=ppc-softmmu --enable-debug make -j8
mkdir foo
touch foo/hello

./ppc-softmmu/qemu-system-ppc -M prep --nographic --monitor null             \
                              -hda fat:rw:./foo

"Ctrl-C"

qemu-system-ppc: block.c:3368: bdrv_close_all: Assertion \
`((&all_bdrv_states)->tqh_first == ((void *)0))' failed.

This is because we reference bs twice in qcow_co_create(..) one time in bdrv_open_blockdev_ref(..) and in blk_insert_bs(..) but we unref it only once in blk_unref which leads to the reference leak.

Note that I didn't tested much QCOW after this change as I don't use it much.

---
 block/qcow.c | 1 +
 1 file changed, 1 insertion(+)
block/qcow.c +1 -0
index 102d058..385d935 100644
@@ -938,6 +938,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
     ret = 0;
 exit:
     blk_unref(qcow_blk);
+    bdrv_unref(bs);
     qcrypto_block_free(crypto);
     return ret;
 }
Signature · 1 line
1.8.3.1
Applied
#1 lore raw

Am 25.07.2018 um 20:07 hat KONRAD Frederic geschrieben:

Quoted 17 lines

Since 42a3e1ab367cdf38cce093de24eb406b99a4ef96 qemu asserts when using the vvfat driver:

git clone git://qemu.org/qemu.git
cd qemu
./configure --target-list=ppc-softmmu --enable-debug make -j8
mkdir foo
touch foo/hello

./ppc-softmmu/qemu-system-ppc -M prep --nographic --monitor null             \
                              -hda fat:rw:./foo

"Ctrl-C"

qemu-system-ppc: block.c:3368: bdrv_close_all: Assertion                     \
   `((&all_bdrv_states)->tqh_first == ((void *)0))' failed.
Quoted 7 lines

This is because we reference bs twice in qcow_co_create(..) one time in bdrv_open_blockdev_ref(..) and in blk_insert_bs(..) but we unref it only once in blk_unref which leads to the reference leak.

Note that I didn't tested much QCOW after this change as I don't use it much.

Thanks, applied to the block branch.

Kevin