Patchwork [14/14] block: Add missing bdrv_delete() for SG_IO BlockDriver in find_image_format()

login
register
mail settings
Submitter Kevin Wolf
Date May 28, 2010, 4:46 p.m.
Message ID <1275065173-24045-15-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/53914/
State New
Headers show

Comments

Kevin Wolf - May 28, 2010, 4:46 p.m.
From: Nicholas A. Bellinger <nab@linux-iscsi.org>

This patch adds a missing bdrv_delete() call in find_image_format() so that a
SG_IO BlockDriver properly releases the temporary BlockDriverState *bs created
from bdrv_file_open()

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Reported-by: Chris Krumme <chris.krumme@windriver.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Patch

diff --git a/block.c b/block.c
index 24c63f6..296de89 100644
--- a/block.c
+++ b/block.c
@@ -332,8 +332,10 @@  static BlockDriver *find_image_format(const char *filename)
         return NULL;
 
     /* Return the raw BlockDriver * to scsi-generic devices */
-    if (bs->sg)
+    if (bs->sg) {
+        bdrv_delete(bs);
         return bdrv_find_format("raw");
+    }
 
     ret = bdrv_pread(bs, 0, buf, sizeof(buf));
     bdrv_delete(bs);