All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: fix bs->file leak in bdrv_new_open_driver()
@ 2017-06-29  6:03 Manos Pitsidianakis
  2017-06-29 11:18 ` Kevin Wolf
  2017-07-06 23:49 ` no-reply
  0 siblings, 2 replies; 9+ messages in thread
From: Manos Pitsidianakis @ 2017-06-29  6:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, Kevin Wolf, Max Reitz

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 <el13635@mail.ntua.gr>
---
 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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-07-07  9:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29  6:03 [Qemu-devel] [PATCH] block: fix bs->file leak in bdrv_new_open_driver() Manos Pitsidianakis
2017-06-29 11:18 ` Kevin Wolf
2017-06-29 12:07   ` Manos Pitsidianakis
2017-06-29 13:57     ` Kevin Wolf
2017-06-29 20:06       ` Manos Pitsidianakis
2017-07-07  9:28         ` Kevin Wolf
2017-07-07  9:53           ` Manos Pitsidianakis
2017-07-06 23:49 ` no-reply
2017-07-07  0:05   ` Fam Zheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.