[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH] block: fix bs->file leak in bdrv_new_open_driver()
From: |
Manos Pitsidianakis |
Subject: |
[Qemu-block] [PATCH] block: fix bs->file leak in bdrv_new_open_driver() |
Date: |
Thu, 29 Jun 2017 09:03:00 +0300 |
bdrv_open_driver() is called in two places, bdrv_new_open_driver() and
bdrv_open_common(). In the latter, failure cleanup in is in its caller,
bdrv_open_inherit(), which unrefs the bs->file of the failed driver open
if it exists. Let's check for this in bdrv_new_open_driver() as well.
Signed-off-by: Manos Pitsidianakis <address@hidden>
---
block.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block.c b/block.c
index 694396281b..aeacd520e0 100644
--- a/block.c
+++ b/block.c
@@ -1165,6 +1165,9 @@ BlockDriverState *bdrv_new_open_driver(BlockDriver *drv,
const char *node_name,
ret = bdrv_open_driver(bs, drv, node_name, bs->options, flags, errp);
if (ret < 0) {
+ if (bs->file != NULL) {
+ bdrv_unref_child(bs, bs->file);
+ }
QDECREF(bs->explicit_options);
QDECREF(bs->options);
bdrv_unref(bs);
--
2.11.0
- [Qemu-block] [PATCH] block: fix bs->file leak in bdrv_new_open_driver(),
Manos Pitsidianakis <=