[IDLESTAT] clear few memory leaks

Message ID 1410949240-22540-1-git-send-email-sanjay.rawat@linaro.org
State New
Headers show

Commit Message

Sanjay Singh Rawat Sept. 17, 2014, 10:20 a.m.
Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---

below are the leaks which this patch clears

72 bytes in 3 blocks are definitely lost in loss record 2 of 9
at 0x4C2ABBD: malloc (vg_replace_malloc.c:296)
by 0x4C2CA8B: realloc (vg_replace_malloc.c:692)
by 0x403636: store_data (idlestat.c:836)

72 bytes in 2 blocks are definitely lost in loss record 4 of 9
at 0x4C2CB0A: realloc (vg_replace_malloc.c:692)
by 0x403820: store_irq (idlestat.c:882)

32,136 bytes in 9 blocks are definitely lost in loss record 9 of 9
at 0x4C2CB0A: realloc (vg_replace_malloc.c:692)
by 0x403636: store_data (idlestat.c:836)
by 0x403E2D: idlestat_load (idlestat.c:1015)
---
 idlestat.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch

diff --git a/idlestat.c b/idlestat.c
index da615cb..4d38d57 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -459,9 +459,16 @@  static void release_cstate_info(struct cpuidle_cstates *cstates, int nrcpus)
 			struct cpuidle_cstate *c = &(cstates[cpu].cstate[i]);
 			if (c->name)
 				free(c->name);
+			if (c->data)
+				free(c->data);
 		}
 	}
 
+	if (cstates->wakeinfo.irqinfo)
+		free(cstates->wakeinfo.irqinfo);
+	if (cstates->wakeirq)
+		free(cstates->wakeirq);
+
 	/* free the cstates array */
 	free(cstates);
 }