]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: fix dangling bs->explicit_options in block.c
authorManos Pitsidianakis <el13635@mail.ntua.gr>
Fri, 14 Jul 2017 14:35:47 +0000 (17:35 +0300)
committerKevin Wolf <kwolf@redhat.com>
Tue, 1 Aug 2017 16:09:33 +0000 (18:09 +0200)
In some error paths it is possible to QDECREF a freed dangling
explicit_options, resulting in a heap overflow crash.  For example
bdrv_open_inherit()'s fail unrefs it, then calls bdrv_unref which calls
bdrv_close which also unrefs it.

Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c

diff --git a/block.c b/block.c
index 37e72b7a96ff1580ffffbbe0c3987a9158d88921..7a78bc647b6314193acdf41bce60c5eabc1a7d02 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2608,6 +2608,7 @@ fail:
     QDECREF(bs->options);
     QDECREF(options);
     bs->options = NULL;
+    bs->explicit_options = NULL;
     bdrv_unref(bs);
     error_propagate(errp, local_err);
     return NULL;
@@ -3087,6 +3088,7 @@ static void bdrv_close(BlockDriverState *bs)
         QDECREF(bs->options);
         QDECREF(bs->explicit_options);
         bs->options = NULL;
+        bs->explicit_options = NULL;
         QDECREF(bs->full_open_options);
         bs->full_open_options = NULL;
     }