]> xenbits.xensource.com Git - qemu-upstream-4.3-testing.git/commitdiff
rbd: always set out parameter in qemu_rbd_snap_list
authorJosh Durgin <josh.durgin@dreamhost.com>
Wed, 7 Dec 2011 01:05:10 +0000 (17:05 -0800)
committerJustin M. Forbes <jforbes@redhat.com>
Tue, 10 Jan 2012 19:37:11 +0000 (13:37 -0600)
The caller expects psn_tab to be NULL when there are no snapshots or
an error occurs. This results in calling g_free on an invalid address.

Reported-by: Oliver Francke <Oliver@filoo.de>
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/rbd.c

index 9088c52d247689ab681c05076a08433eb45dfbc8..54a6961737f760166ffc64233fa81653aa628381 100644 (file)
@@ -808,7 +808,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
     } while (snap_count == -ERANGE);
 
     if (snap_count <= 0) {
-        return snap_count;
+        goto done;
     }
 
     sn_tab = g_malloc0(snap_count * sizeof(QEMUSnapshotInfo));
@@ -827,6 +827,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
     }
     rbd_snap_list_end(snaps);
 
+ done:
     *psn_tab = sn_tab;
     return snap_count;
 }