[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 10/79] block: Do not unref bs->file on error in BD'
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 10/79] block: Do not unref bs->file on error in BD's open |
Date: |
Mon, 28 Aug 2017 19:13:45 -0500 |
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>
(cherry picked from commit de234897b60e034ba94b307fc289e2dc692c9251)
Signed-off-by: Michael Roth <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;
}
--
2.7.4
- [Qemu-stable] [PATCH 00/79] Patch Round-up for stable 2.9.1, freeze on 2017-09-04, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 10/79] block: Do not unref bs->file on error in BD's open,
Michael Roth <=
- [Qemu-stable] [PATCH 12/79] replication: Make --disable-replication compile again, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 11/79] ACPI: don't call acpi_pcihp_device_plug_cb on xen, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 09/79] pci: deassert intx when pci device unrealize, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 14/79] coccinelle: Add script to remove useless QObject casts, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 16/79] qobject: Add helper macros for common scalar insertions, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 13/79] 9pfs: local: fix unlink of alien files in mapped-file mode, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 01/79] qga-win: Enable 'can-offline' field in 'guest-get-vcpus' reply, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 19/79] block: Reuse bs as backing hd for drive-backup sync=none, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 15/79] qobject: Drop useless QObject casts, Michael Roth, 2017/08/28
- [Qemu-stable] [PATCH 17/79] s390x: Drop useless casts, Michael Roth, 2017/08/28