[Sheepdog] PATCH S007: Fix two memory leaks

Shevek shevek at anarres.org
Thu May 10 03:40:00 CEST 2012


==7463== 72 bytes in 1 blocks are definitely lost in loss record 11 of
38
==7463== at 0x4C279F2: calloc (vg_replace_malloc.c:467)
==7463== by 0x404423: zalloc (util.h:58)
==7463== by 0x408090: sd_join_handler (group.c:1181)
==7463== by 0x41BFA1: __corosync_dispatch_one (corosync.c:496)
==7463== by 0x41C421: __corosync_dispatch (corosync.c:582)
==7463== by 0x41CC8D: cdrv_cpg_deliver (corosync.c:741)
==7463== by 0x504E978: cpg_dispatch (cpg.c:390)
==7463== by 0x41D646: corosync_dispatch (corosync.c:981)
==7463== by 0x4053FB: group_handler (group.c:283)
==7463== by 0x421DA3: event_loop (event.c:181)
==7463== by 0x40425F: main (sheep.c:272)
==7463==

==7463== 544 bytes in 1 blocks are definitely lost in loss record 29 of
38
==7463== at 0x4C28F9F: malloc (vg_replace_malloc.c:236)
==7463== by 0x424004: xmalloc (util.c:36)
==7463== by 0x4240AF: xzalloc (util.c:53)
==7463== by 0x410F78: jrnl_begin (journal.c:186)
==7463== by 0x40DD71: set_cluster_store (store.c:1209)
==7463== by 0x405F13: finish_join (group.c:552)
==7463== by 0x4061C2: update_cluster_info (group.c:598)
==7463== by 0x406F70: __sd_join_done (group.c:845)
==7463== by 0x40753B: event_done (group.c:959)
==7463== by 0x4105D2: bs_thread_request_done (work.c:178)
==7463== by 0x421DA3: event_loop (event.c:181)
==7463== by 0x40425F: main (sheep.c:272)

Before these two fixes, I get a lot of lost data.

With these two fixes, I get 0 bytes definitely lost.

Signed-off-by: Shevek <shevek at anarres.org>

---
 sheep/group.c   |    1 +
 sheep/journal.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index c7fd387..855e70e 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -882,6 +882,7 @@ static void event_free(struct event_struct *cevent)
 	case EVENT_JOIN: {
 		struct work_join *w = container_of(cevent, struct work_join, cev);
 		free(w->member_list);
+		free(w->jm);
 		free(w);
 		break;
 	}
diff --git a/sheep/journal.c b/sheep/journal.c
index 965e152..d082aa2 100644
--- a/sheep/journal.c
+++ b/sheep/journal.c
@@ -224,6 +224,7 @@ int jrnl_end(struct jrnl_descriptor * jd)
 
 	ret = jrnl_remove(jd);
 err:
+	free(jd);
 	return ret;
 }
 
-- 
1.7.5.4






More information about the sheepdog mailing list