|
|
3465fa |
From 3acda11a1add5b08d3b2f26dcb96de06581ff094 Mon Sep 17 00:00:00 2001
|
|
|
3465fa |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
3465fa |
Date: Wed, 25 Sep 2013 16:00:48 +0200
|
|
|
3465fa |
Subject: [PATCH] rbd: avoid qemu_rbd_snap_list() memory leaks
|
|
|
3465fa |
MIME-Version: 1.0
|
|
|
3465fa |
Content-Type: text/plain; charset=UTF-8
|
|
|
3465fa |
Content-Transfer-Encoding: 8bit
|
|
|
3465fa |
|
|
|
3465fa |
RH-Author: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
3465fa |
RH-MergeRequest: 118: rbd: avoid qemu_rbd_snap_list() memory leaks
|
|
|
3465fa |
RH-Commit: [1/1] b7270277ecf931b119d5606f644793f32478e4c4
|
|
|
3465fa |
RH-Bugzilla: 2056725
|
|
|
3465fa |
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
3465fa |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
3465fa |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
3465fa |
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
3465fa |
|
|
|
3465fa |
When there are no snapshots qemu_rbd_snap_list() returns 0 and the
|
|
|
3465fa |
snapshot table pointer is NULL. Don't forget to free the snaps buffer
|
|
|
3465fa |
we allocated for librbd rbd_snap_list().
|
|
|
3465fa |
|
|
|
3465fa |
When the function succeeds don't forget to free the snaps buffer after
|
|
|
3465fa |
calling rbd_snap_list_end().
|
|
|
3465fa |
|
|
|
3465fa |
Cc: qemu-stable@nongnu.org
|
|
|
3465fa |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
3465fa |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
3465fa |
(cherry picked from commit 9e6337d0818650362149b734d53edf9489f3acaa)
|
|
|
3465fa |
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
3465fa |
---
|
|
|
3465fa |
block/rbd.c | 3 ++-
|
|
|
3465fa |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
3465fa |
|
|
|
3465fa |
diff --git a/block/rbd.c b/block/rbd.c
|
|
|
3465fa |
index b982658db4..996e86272e 100644
|
|
|
3465fa |
--- a/block/rbd.c
|
|
|
3465fa |
+++ b/block/rbd.c
|
|
|
3465fa |
@@ -952,7 +952,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
|
|
|
3465fa |
do {
|
|
|
3465fa |
snaps = g_malloc(sizeof(*snaps) * max_snaps);
|
|
|
3465fa |
snap_count = rbd_snap_list(s->image, snaps, &max_snaps);
|
|
|
3465fa |
- if (snap_count < 0) {
|
|
|
3465fa |
+ if (snap_count <= 0) {
|
|
|
3465fa |
g_free(snaps);
|
|
|
3465fa |
}
|
|
|
3465fa |
} while (snap_count == -ERANGE);
|
|
|
3465fa |
@@ -976,6 +976,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
|
|
|
3465fa |
sn_info->vm_clock_nsec = 0;
|
|
|
3465fa |
}
|
|
|
3465fa |
rbd_snap_list_end(snaps);
|
|
|
3465fa |
+ g_free(snaps);
|
|
|
3465fa |
|
|
|
3465fa |
done:
|
|
|
3465fa |
*psn_tab = sn_tab;
|
|
|
3465fa |
--
|
|
|
3465fa |
2.27.0
|
|
|
3465fa |
|