[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    perf annotate: Fix memory leaks in LOCK handling
From:       "Linux Kernel Mailing List" <linux-kernel () vger ! kernel ! org>
Date:       2015-01-31 0:38:00
Message-ID: 20150131003800.54C3E660CBB () gitolite ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/linus/;a=commit;h=0fb9f2aab738eec9dd9b929ed7d37bf744d2ac77
Commit:     0fb9f2aab738eec9dd9b929ed7d37bf744d2ac77
Parent:     be81908c2289f405df75d2511ccf5da785945400
Refname:    refs/heads/master
Author:     Rabin Vincent <rabin@rab.in>
AuthorDate: Sun Jan 18 20:00:21 2015 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed Jan 21 10:05:32 2015 -0300

    perf annotate: Fix memory leaks in LOCK handling
    
    The lock prefix handling fails to free the strdup()'d name as well as
    the fields allocated by the instruction parsing.
    
    Signed-off-by: Rabin Vincent <rabin@rab.in>
    Cc: Paul Mackerras <paulus@samba.org>
    Link: http://lkml.kernel.org/r/1421607621-15005-2-git-send-email-rabin@rab.in
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index d5da1b8..01bc4e2 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -177,6 +177,8 @@ static int lock__parse(struct ins_operands *ops)
 		goto out_free_ops;
 
 	ops->locked.ins = ins__find(name);
+	free(name);
+
 	if (ops->locked.ins == NULL)
 		goto out_free_ops;
 
@@ -209,6 +211,13 @@ static int lock__scnprintf(struct ins *ins, char *bf, size_t size,
 
 static void lock__delete(struct ins_operands *ops)
 {
+	struct ins *ins = ops->locked.ins;
+
+	if (ins && ins->ops->free)
+		ins->ops->free(ops->locked.ops);
+	else
+		ins__delete(ops->locked.ops);
+
 	zfree(&ops->locked.ops);
 	zfree(&ops->target.raw);
 	zfree(&ops->target.name);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic