[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 18/34] block: Do not unref bs->file on error in BD's
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 18/34] block: Do not unref bs->file on error in BD's open |
Date: |
Fri, 28 Apr 2017 22:33:26 +0200 |
From: Max Reitz <address@hidden>
The block layer takes care of removing the bs->file child if the block
driver's bdrv_open()/bdrv_file_open() implementation fails. The block
driver therefore does not need to do so, and indeed should not unless it
sets bs->file to NULL afterwards -- because if this is not done, the
bdrv_unref_child() in bdrv_open_inherit() will dereference the freed
memory block at bs->file afterwards, which is not good.
We can now decide whether to add a "bs->file = NULL;" after each of the
offending bdrv_unref_child() invocations, or just drop them altogether.
The latter is simpler, so let's do that.
Cc: qemu-stable <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/blkdebug.c | 4 +---
block/blkreplay.c | 3 ---
block/blkverify.c | 3 ---
3 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 67e8024..cc4a146 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -389,14 +389,12 @@ static int blkdebug_open(BlockDriverState *bs, QDict
*options, int flags,
} else if (align) {
error_setg(errp, "Invalid alignment");
ret = -EINVAL;
- goto fail_unref;
+ goto out;
}
ret = 0;
goto out;
-fail_unref:
- bdrv_unref_child(bs, bs->file);
out:
if (ret < 0) {
g_free(s->config_file);
diff --git a/block/blkreplay.c b/block/blkreplay.c
index e110211..6aa5fd4 100755
--- a/block/blkreplay.c
+++ b/block/blkreplay.c
@@ -37,9 +37,6 @@ static int blkreplay_open(BlockDriverState *bs, QDict
*options, int flags,
ret = 0;
fail:
- if (ret < 0) {
- bdrv_unref_child(bs, bs->file);
- }
return ret;
}
diff --git a/block/blkverify.c b/block/blkverify.c
index 9a1e21c..af23281 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -142,9 +142,6 @@ static int blkverify_open(BlockDriverState *bs, QDict
*options, int flags,
ret = 0;
fail:
- if (ret < 0) {
- bdrv_unref_child(bs, bs->file);
- }
qemu_opts_del(opts);
return ret;
}
--
1.8.3.1
- [Qemu-block] [PULL 09/34] block: An empty filename counts as no filename, (continued)
- [Qemu-block] [PULL 09/34] block: An empty filename counts as no filename, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 10/34] iotests/051: Add test for empty filename, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 11/34] qemu-iotests: Remove PERL_PROG and BC_PROG, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 12/34] qemu_iotests: Remove _readlink(), Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 13/34] block: Remove NULL check in bdrv_co_flush, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 14/34] iotests: Launch qemu-nbd with -e 42, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 15/34] Issue a deprecation warning if the user specifies the "-hdachs" option., Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 16/34] iotests: Fix typo in 026, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 07/34] qemu-iotests: Filter HMP readline escape characters, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 17/34] iotests: 109: Filter out "len" of failed jobs, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 18/34] block: Do not unref bs->file on error in BD's open,
Kevin Wolf <=
- [Qemu-block] [PULL 19/34] block: fix alignment calculations in bdrv_co_do_zero_pwritev, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 20/34] qemu-img/convert: Use @opts for one thing only, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 23/34] block/vhdx: Make vhdx_create() always set errp, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 21/34] qemu-img/convert: Move bs_n > 1 && -B check down, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 22/34] qemu-img: Document backing options, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 24/34] block: Add errp to b{lk,drv}_truncate(), Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 27/34] qcow2: Allow discard of final unaligned cluster, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 26/34] block: Add .bdrv_truncate() error messages, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 28/34] block: fix obvious coding style mistakes in block_int.h, Kevin Wolf, 2017/04/28
- [Qemu-block] [PULL 25/34] block: Add errp to BD.bdrv_truncate(), Kevin Wolf, 2017/04/28