Skip to content

Commit

Permalink
perf annotate: Fix memory leaks in LOCK handling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rabin Vincent authored and Arnaldo Carvalho de Melo committed Jan 21, 2015
1 parent be81908 commit 0fb9f2a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0fb9f2a

Please sign in to comment.