[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/30] rbd: avoid qemu_rbd_snap_list() memory leaks
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 13/30] rbd: avoid qemu_rbd_snap_list() memory leaks |
Date: |
Fri, 27 Sep 2013 17:39:13 +0200 |
From: Stefan Hajnoczi <address@hidden>
When there are no snapshots qemu_rbd_snap_list() returns 0 and the
snapshot table pointer is NULL. Don't forget to free the snaps buffer
we allocated for librbd rbd_snap_list().
When the function succeeds don't forget to free the snaps buffer after
calling rbd_snap_list_end().
Cc: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/rbd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/rbd.c b/block/rbd.c
index f6d3237..4a1ea5b 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -943,7 +943,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
do {
snaps = g_malloc(sizeof(*snaps) * max_snaps);
snap_count = rbd_snap_list(s->image, snaps, &max_snaps);
- if (snap_count < 0) {
+ if (snap_count <= 0) {
g_free(snaps);
}
} while (snap_count == -ERANGE);
@@ -967,6 +967,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
sn_info->vm_clock_nsec = 0;
}
rbd_snap_list_end(snaps);
+ g_free(snaps);
done:
*psn_tab = sn_tab;
--
1.8.1.4
- [Qemu-devel] [PULL 10/30] block: introduce BlockDriver.bdrv_needs_filename to enable some drivers., (continued)
- [Qemu-devel] [PULL 10/30] block: introduce BlockDriver.bdrv_needs_filename to enable some drivers., Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 11/30] block: Fix compiler warning (-Werror=uninitialized), Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 07/30] vmdk: fix cluster size check for flat extents, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 09/30] qemu-iotests: add monolithicFlat creation test to 059, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 08/30] qemu-iotests: fix test case 059, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 17/30] block: qed - use QEMU_PACKED for on-disk structures, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 12/30] qdict: Extract qdict_extract_subqdict, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 15/30] block: vpc - use QEMU_PACKED for on-disk structures, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 20/30] qemu-iotests: fix qmp.py search path, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 14/30] block: vdi - use QEMU_PACKED for on-disk structures, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 13/30] rbd: avoid qemu_rbd_snap_list() memory leaks,
Kevin Wolf <=
- [Qemu-devel] [PULL 18/30] qcow2: Assert against currently impossible overflow, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 16/30] block: qcow2 - used QEMU_PACKED for on-disk structures, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 19/30] block: use DIV_ROUND_UP in bdrv_co_do_readv, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 21/30] qemu-iotests: Add basic ability to use binary sample images, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 22/30] qemu-iotests: Quote $TEST_IMG* and $TEST_DIR usage, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 26/30] qcow2: Always use error path in l2_allocate, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 28/30] qcow2: count_contiguous_clusters and compression, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 27/30] qcow2: Free only newly allocated clusters on error, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 29/30] qcow2: COMPRESSED on count_contiguous_clusters, Kevin Wolf, 2013/09/27
- [Qemu-devel] [PULL 30/30] qcow2: Remove useless count_contiguous_clusters() parameter, Kevin Wolf, 2013/09/27