* [PATCH 1/2] perf annotate: handle ins parsing failures
@ 2015-01-18 19:00 Rabin Vincent
2015-01-18 19:00 ` [PATCH 2/2] perf annotate: fix memory leaks in LOCK handling Rabin Vincent
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Rabin Vincent @ 2015-01-18 19:00 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Paul Mackerras, Arnaldo Carvalho de Melo
Cc: linux-kernel, Rabin Vincent
Don't use the ins's ->sncprintf() if the parsing failed.
For example, this fixes the display of "imul %edx". Without this patch:
| imul (null),(null)
After this patch:
| imul %edx
Signed-off-by: Rabin Vincent <rabin@rab.in>
---
tools/perf/util/annotate.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 79999ce..5ae428b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -183,8 +183,9 @@ static int lock__parse(struct ins_operands *ops)
if (!ops->locked.ins->ops)
return 0;
- if (ops->locked.ins->ops->parse)
- ops->locked.ins->ops->parse(ops->locked.ops);
+ if (ops->locked.ins->ops->parse
+ && ops->locked.ins->ops->parse(ops->locked.ops) < 0)
+ goto out_free_ops;
return 0;
@@ -531,8 +532,8 @@ static void disasm_line__init_ins(struct disasm_line *dl)
if (!dl->ins->ops)
return;
- if (dl->ins->ops->parse)
- dl->ins->ops->parse(&dl->ops);
+ if (dl->ins->ops->parse && dl->ins->ops->parse(&dl->ops) < 0)
+ dl->ins = NULL;
}
static int disasm_line__parse(char *line, char **namep, char **rawp)
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] perf annotate: fix memory leaks in LOCK handling
2015-01-18 19:00 [PATCH 1/2] perf annotate: handle ins parsing failures Rabin Vincent
@ 2015-01-18 19:00 ` Rabin Vincent
2015-01-28 15:01 ` [tip:perf/core] perf annotate: Fix " tip-bot for Rabin Vincent
2015-01-19 15:08 ` [PATCH 1/2] perf annotate: handle ins parsing failures Arnaldo Carvalho de Melo
2015-01-28 15:00 ` [tip:perf/core] perf annotate: Handle " tip-bot for Rabin Vincent
2 siblings, 1 reply; 5+ messages in thread
From: Rabin Vincent @ 2015-01-18 19:00 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Paul Mackerras, Arnaldo Carvalho de Melo
Cc: linux-kernel, Rabin Vincent
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>
---
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 5ae428b..53d11c1 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);
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] perf annotate: handle ins parsing failures
2015-01-18 19:00 [PATCH 1/2] perf annotate: handle ins parsing failures Rabin Vincent
2015-01-18 19:00 ` [PATCH 2/2] perf annotate: fix memory leaks in LOCK handling Rabin Vincent
@ 2015-01-19 15:08 ` Arnaldo Carvalho de Melo
2015-01-28 15:00 ` [tip:perf/core] perf annotate: Handle " tip-bot for Rabin Vincent
2 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-01-19 15:08 UTC (permalink / raw)
To: Rabin Vincent; +Cc: Ingo Molnar, Peter Zijlstra, Paul Mackerras, linux-kernel
Em Sun, Jan 18, 2015 at 08:00:20PM +0100, Rabin Vincent escreveu:
> Don't use the ins's ->sncprintf() if the parsing failed.
>
> For example, this fixes the display of "imul %edx". Without this patch:
>
> | imul (null),(null)
>
> After this patch:
>
> | imul %edx
Thanks, both applied!
- Arnaldo
> Signed-off-by: Rabin Vincent <rabin@rab.in>
> ---
> tools/perf/util/annotate.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index 79999ce..5ae428b 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -183,8 +183,9 @@ static int lock__parse(struct ins_operands *ops)
> if (!ops->locked.ins->ops)
> return 0;
>
> - if (ops->locked.ins->ops->parse)
> - ops->locked.ins->ops->parse(ops->locked.ops);
> + if (ops->locked.ins->ops->parse
> + && ops->locked.ins->ops->parse(ops->locked.ops) < 0)
> + goto out_free_ops;
>
> return 0;
>
> @@ -531,8 +532,8 @@ static void disasm_line__init_ins(struct disasm_line *dl)
> if (!dl->ins->ops)
> return;
>
> - if (dl->ins->ops->parse)
> - dl->ins->ops->parse(&dl->ops);
> + if (dl->ins->ops->parse && dl->ins->ops->parse(&dl->ops) < 0)
> + dl->ins = NULL;
> }
>
> static int disasm_line__parse(char *line, char **namep, char **rawp)
> --
> 2.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip:perf/core] perf annotate: Handle ins parsing failures
2015-01-18 19:00 [PATCH 1/2] perf annotate: handle ins parsing failures Rabin Vincent
2015-01-18 19:00 ` [PATCH 2/2] perf annotate: fix memory leaks in LOCK handling Rabin Vincent
2015-01-19 15:08 ` [PATCH 1/2] perf annotate: handle ins parsing failures Arnaldo Carvalho de Melo
@ 2015-01-28 15:00 ` tip-bot for Rabin Vincent
2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Rabin Vincent @ 2015-01-28 15:00 UTC (permalink / raw)
To: linux-tip-commits
Cc: peterz, tglx, paulus, rabin, linux-kernel, mingo, acme, hpa
Commit-ID: be81908c2289f405df75d2511ccf5da785945400
Gitweb: http://git.kernel.org/tip/be81908c2289f405df75d2511ccf5da785945400
Author: Rabin Vincent <rabin@rab.in>
AuthorDate: Sun, 18 Jan 2015 20:00:20 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 21 Jan 2015 10:05:17 -0300
perf annotate: Handle ins parsing failures
Don't use the ins's ->sncprintf() if the parsing failed.
For example, this fixes the display of "imul %edx". Without this patch:
| imul (null),(null)
After this patch:
| imul %edx
Signed-off-by: Rabin Vincent <rabin@rab.in>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1421607621-15005-1-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, 5 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 79999ce..d5da1b8 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -183,8 +183,9 @@ static int lock__parse(struct ins_operands *ops)
if (!ops->locked.ins->ops)
return 0;
- if (ops->locked.ins->ops->parse)
- ops->locked.ins->ops->parse(ops->locked.ops);
+ if (ops->locked.ins->ops->parse &&
+ ops->locked.ins->ops->parse(ops->locked.ops) < 0)
+ goto out_free_ops;
return 0;
@@ -531,8 +532,8 @@ static void disasm_line__init_ins(struct disasm_line *dl)
if (!dl->ins->ops)
return;
- if (dl->ins->ops->parse)
- dl->ins->ops->parse(&dl->ops);
+ if (dl->ins->ops->parse && dl->ins->ops->parse(&dl->ops) < 0)
+ dl->ins = NULL;
}
static int disasm_line__parse(char *line, char **namep, char **rawp)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [tip:perf/core] perf annotate: Fix memory leaks in LOCK handling
2015-01-18 19:00 ` [PATCH 2/2] perf annotate: fix memory leaks in LOCK handling Rabin Vincent
@ 2015-01-28 15:01 ` tip-bot for Rabin Vincent
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Rabin Vincent @ 2015-01-28 15:01 UTC (permalink / raw)
To: linux-tip-commits; +Cc: tglx, acme, hpa, paulus, rabin, linux-kernel, mingo
Commit-ID: 0fb9f2aab738eec9dd9b929ed7d37bf744d2ac77
Gitweb: http://git.kernel.org/tip/0fb9f2aab738eec9dd9b929ed7d37bf744d2ac77
Author: Rabin Vincent <rabin@rab.in>
AuthorDate: Sun, 18 Jan 2015 20:00:21 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 21 Jan 2015 10:05:32 -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);
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-01-28 20:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-18 19:00 [PATCH 1/2] perf annotate: handle ins parsing failures Rabin Vincent
2015-01-18 19:00 ` [PATCH 2/2] perf annotate: fix memory leaks in LOCK handling Rabin Vincent
2015-01-28 15:01 ` [tip:perf/core] perf annotate: Fix " tip-bot for Rabin Vincent
2015-01-19 15:08 ` [PATCH 1/2] perf annotate: handle ins parsing failures Arnaldo Carvalho de Melo
2015-01-28 15:00 ` [tip:perf/core] perf annotate: Handle " tip-bot for Rabin Vincent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).