]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
block: Check bdrv_getlength() return value in bdrv_append_temp_snapshot()
authorKevin Wolf <kwolf@redhat.com>
Fri, 4 Apr 2014 15:07:19 +0000 (17:07 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 4 Apr 2014 17:35:52 +0000 (19:35 +0200)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
block.c

diff --git a/block.c b/block.c
index d89c344a13fe0bbc27e28cf86507ba88391a3314..990a7542a9495ade8237e7b13a68216cc6300bd2 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1184,7 +1184,12 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp)
        instead of opening 'filename' directly */
 
     /* Get the required size from the image */
-    total_size = bdrv_getlength(bs) & BDRV_SECTOR_MASK;
+    total_size = bdrv_getlength(bs);
+    if (total_size < 0) {
+        error_setg_errno(errp, -total_size, "Could not get image size");
+        return;
+    }
+    total_size &= BDRV_SECTOR_MASK;
 
     /* Create the temporary image */
     ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));