[sheepdog] [PATCH] md: fix memory leak after removing the disk

Liu Yuan namei.unix at gmail.com
Wed Sep 4 11:38:47 CEST 2013


Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/md.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sheep/md.c b/sheep/md.c
index b79fde4..37feeb2 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -283,6 +283,12 @@ bool md_add_disk(const char *path)
 	return true;
 }
 
+static inline void vdisk_free(struct vdisk *v)
+{
+	rb_erase(&v->rb, &md.vroot);
+	free(v);
+}
+
 static inline void md_remove_disk(struct disk *disk)
 {
 	struct vdisk *v;
@@ -292,7 +298,7 @@ static inline void md_remove_disk(struct disk *disk)
 	md.nr_disks--;
 	rb_for_each_entry(v, &md.vroot, rb) {
 		if (v->disk == disk)
-			rb_erase(&v->rb, &md.vroot);
+			vdisk_free(v);
 	}
 	free(disk);
 }
-- 
1.7.9.5




More information about the sheepdog mailing list