Patchwork qemu-img rebase: Fix segfault if backing file can't be opened

login
register
mail settings
Submitter Kevin Wolf
Date March 31, 2011, 10:41 a.m.
Message ID <1301568097-8319-1-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/89059/
State New
Headers show

Comments

Kevin Wolf - March 31, 2011, 10:41 a.m.
bdrv_delete must not be called for a NULL BlockDriverState.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-img.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
Stefan Hajnoczi - March 31, 2011, 11:54 a.m.
On Thu, Mar 31, 2011 at 11:41 AM, Kevin Wolf <kwolf@redhat.com> wrote:
> bdrv_delete must not be called for a NULL BlockDriverState.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qemu-img.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 074388c..d9c2c12 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1411,8 +1411,12 @@  out:
     qemu_progress_end();
     /* Cleanup */
     if (!unsafe) {
-        bdrv_delete(bs_old_backing);
-        bdrv_delete(bs_new_backing);
+        if (bs_old_backing != NULL) {
+            bdrv_delete(bs_old_backing);
+        }
+        if (bs_new_backing != NULL) {
+            bdrv_delete(bs_new_backing);
+        }
     }
 
     bdrv_delete(bs);