* [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type
@ 2019-10-25 8:23 Hewenliang
2019-11-13 19:46 ` Steven Rostedt
2019-11-18 14:28 ` [PATCH v2] tools lib traceevent: " Steven Rostedt
0 siblings, 2 replies; 12+ messages in thread
From: Hewenliang @ 2019-10-25 8:23 UTC (permalink / raw)
To: acme, tstoyanov, rostedt, namhyung, linux-kernel; +Cc: linfeilong, hewenliang4
It is necessary to free the memory that we have allocated
when error occurs.
Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
Signed-off-by: Hewenliang <hewenliang4@huawei.com>
---
tools/lib/traceevent/parse-filter.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 552592d153fb..fbaa790d10d8 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
/* Add trivial event */
arg = allocate_arg();
- if (arg == NULL)
+ if (arg == NULL) {
+ free(str);
return -1;
+ }
arg->type = TEP_FILTER_ARG_BOOLEAN;
if (strcmp(str, "TRUE") == 0)
@@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
arg->boolean.value = 0;
filter_type = add_filter_type(filter, event->id);
- if (filter_type == NULL)
+ if (filter_type == NULL) {
+ free(str);
+ free(arg);
return -1;
+ }
filter_type->filter = arg;
--
2.19.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-10-25 8:23 [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type Hewenliang
@ 2019-11-13 19:46 ` Steven Rostedt
2019-11-13 19:47 ` Steven Rostedt
2019-11-13 20:37 ` Arnaldo Carvalho de Melo
2019-11-18 14:28 ` [PATCH v2] tools lib traceevent: " Steven Rostedt
1 sibling, 2 replies; 12+ messages in thread
From: Steven Rostedt @ 2019-11-13 19:46 UTC (permalink / raw)
To: Hewenliang, acme; +Cc: tstoyanov, namhyung, linux-kernel, linfeilong
On Fri, 25 Oct 2019 04:23:12 -0400
Hewenliang <hewenliang4@huawei.com> wrote:
> It is necessary to free the memory that we have allocated
> when error occurs.
>
> Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> Signed-off-by: Hewenliang <hewenliang4@huawei.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Arnaldo,
Can you take this?
-- Steve
> ---
> tools/lib/traceevent/parse-filter.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> index 552592d153fb..fbaa790d10d8 100644
> --- a/tools/lib/traceevent/parse-filter.c
> +++ b/tools/lib/traceevent/parse-filter.c
> @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
> if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
> /* Add trivial event */
> arg = allocate_arg();
> - if (arg == NULL)
> + if (arg == NULL) {
> + free(str);
> return -1;
> + }
>
> arg->type = TEP_FILTER_ARG_BOOLEAN;
> if (strcmp(str, "TRUE") == 0)
> @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
> arg->boolean.value = 0;
>
> filter_type = add_filter_type(filter, event->id);
> - if (filter_type == NULL)
> + if (filter_type == NULL) {
> + free(str);
> + free(arg);
> return -1;
> + }
>
> filter_type->filter = arg;
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-11-13 19:46 ` Steven Rostedt
@ 2019-11-13 19:47 ` Steven Rostedt
2019-11-13 20:37 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 12+ messages in thread
From: Steven Rostedt @ 2019-11-13 19:47 UTC (permalink / raw)
To: Hewenliang, acme; +Cc: tstoyanov, namhyung, linux-kernel, linfeilong
On Wed, 13 Nov 2019 14:46:26 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Fri, 25 Oct 2019 04:23:12 -0400
> Hewenliang <hewenliang4@huawei.com> wrote:
>
> > It is necessary to free the memory that we have allocated
> > when error occurs.
> >
> > Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> > Signed-off-by: Hewenliang <hewenliang4@huawei.com>
>
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
After I sent this, I found an issue.
>
> Arnaldo,
>
> Can you take this?
Don't take it.
>
> > ---
> > tools/lib/traceevent/parse-filter.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> > index 552592d153fb..fbaa790d10d8 100644
> > --- a/tools/lib/traceevent/parse-filter.c
> > +++ b/tools/lib/traceevent/parse-filter.c
> > @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
> > if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
> > /* Add trivial event */
> > arg = allocate_arg();
> > - if (arg == NULL)
> > + if (arg == NULL) {
> > + free(str);
> > return -1;
> > + }
> >
> > arg->type = TEP_FILTER_ARG_BOOLEAN;
> > if (strcmp(str, "TRUE") == 0)
> > @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
> > arg->boolean.value = 0;
> >
> > filter_type = add_filter_type(filter, event->id);
> > - if (filter_type == NULL)
> > + if (filter_type == NULL) {
> > + free(str);
> > + free(arg);
This needs to be: free_arg(arg);
-- Steve
> > return -1;
> > + }
> >
> > filter_type->filter = arg;
> >
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-11-13 19:46 ` Steven Rostedt
2019-11-13 19:47 ` Steven Rostedt
@ 2019-11-13 20:37 ` Arnaldo Carvalho de Melo
2019-11-13 20:40 ` Steven Rostedt
1 sibling, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-11-13 20:37 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Hewenliang, tstoyanov, namhyung, linux-kernel, linfeilong
Em Wed, Nov 13, 2019 at 02:46:26PM -0500, Steven Rostedt escreveu:
> On Fri, 25 Oct 2019 04:23:12 -0400
> Hewenliang <hewenliang4@huawei.com> wrote:
>
> > It is necessary to free the memory that we have allocated
> > when error occurs.
> >
> > Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> > Signed-off-by: Hewenliang <hewenliang4@huawei.com>
>
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> Arnaldo,
sure
> Can you take this?
>
> -- Steve
>
> > ---
> > tools/lib/traceevent/parse-filter.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> > index 552592d153fb..fbaa790d10d8 100644
> > --- a/tools/lib/traceevent/parse-filter.c
> > +++ b/tools/lib/traceevent/parse-filter.c
> > @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
> > if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
> > /* Add trivial event */
> > arg = allocate_arg();
> > - if (arg == NULL)
> > + if (arg == NULL) {
> > + free(str);
> > return -1;
> > + }
> >
> > arg->type = TEP_FILTER_ARG_BOOLEAN;
> > if (strcmp(str, "TRUE") == 0)
> > @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
> > arg->boolean.value = 0;
> >
> > filter_type = add_filter_type(filter, event->id);
> > - if (filter_type == NULL)
> > + if (filter_type == NULL) {
> > + free(str);
> > + free(arg);
> > return -1;
> > + }
> >
> > filter_type->filter = arg;
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-11-13 20:37 ` Arnaldo Carvalho de Melo
@ 2019-11-13 20:40 ` Steven Rostedt
2019-11-13 23:01 ` Arnaldo Carvalho de Melo
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Steven Rostedt @ 2019-11-13 20:40 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Hewenliang, tstoyanov, namhyung, linux-kernel, linfeilong
On Wed, 13 Nov 2019 18:37:10 -0200
Arnaldo Carvalho de Melo <acme@redhat.com> wrote:
> Em Wed, Nov 13, 2019 at 02:46:26PM -0500, Steven Rostedt escreveu:
> > On Fri, 25 Oct 2019 04:23:12 -0400
> > Hewenliang <hewenliang4@huawei.com> wrote:
> >
> > > It is necessary to free the memory that we have allocated
> > > when error occurs.
> > >
> > > Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> > > Signed-off-by: Hewenliang <hewenliang4@huawei.com>
> >
> > Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> >
> > Arnaldo,
>
> sure
I found an issue with it (if you didn't see the next email).
Please don't take it.
Thanks!
-- Steve
>
> > Can you take this?
> >
> > -- Steve
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-11-13 20:40 ` Steven Rostedt
@ 2019-11-13 23:01 ` Arnaldo Carvalho de Melo
2019-11-18 3:42 ` Hewenliang
2019-11-19 1:44 ` [PATCH v2] " Hewenliang
2 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-11-13 23:01 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Hewenliang, tstoyanov, namhyung, linux-kernel, linfeilong
Em Wed, Nov 13, 2019 at 03:40:44PM -0500, Steven Rostedt escreveu:
> On Wed, 13 Nov 2019 18:37:10 -0200
> Arnaldo Carvalho de Melo <acme@redhat.com> wrote:
>
> > Em Wed, Nov 13, 2019 at 02:46:26PM -0500, Steven Rostedt escreveu:
> > > On Fri, 25 Oct 2019 04:23:12 -0400
> > > Hewenliang <hewenliang4@huawei.com> wrote:
> > >
> > > > It is necessary to free the memory that we have allocated
> > > > when error occurs.
> > > >
> > > > Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> > > > Signed-off-by: Hewenliang <hewenliang4@huawei.com>
> > >
> > > Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > >
> > > Arnaldo,
> >
> > sure
>
> I found an issue with it (if you didn't see the next email).
>
> Please don't take it.
ok.
> Thanks!
>
> -- Steve
>
> >
> > > Can you take this?
> > >
> > > -- Steve
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-11-13 20:40 ` Steven Rostedt
2019-11-13 23:01 ` Arnaldo Carvalho de Melo
@ 2019-11-18 3:42 ` Hewenliang
2019-11-19 1:44 ` [PATCH v2] " Hewenliang
2 siblings, 0 replies; 12+ messages in thread
From: Hewenliang @ 2019-11-18 3:42 UTC (permalink / raw)
To: rostedt, acme, tstoyanov, namhyung, linux-kernel; +Cc: linfeilong, hushiyuan
It is necessary to free the memory that we have allocated when error occurs.
Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
Signed-off-by: Hewenliang <hewenliang4@huawei.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
tools/lib/traceevent/parse-filter.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 552592d153fb..f3cbf86e51ac 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
/* Add trivial event */
arg = allocate_arg();
- if (arg == NULL)
+ if (arg == NULL) {
+ free(str);
return -1;
+ }
arg->type = TEP_FILTER_ARG_BOOLEAN;
if (strcmp(str, "TRUE") == 0)
@@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
arg->boolean.value = 0;
filter_type = add_filter_type(filter, event->id);
- if (filter_type == NULL)
+ if (filter_type == NULL) {
+ free(str);
+ free_arg(arg);
return -1;
+ }
filter_type->filter = arg;
--
2.19.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-10-25 8:23 [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type Hewenliang
2019-11-13 19:46 ` Steven Rostedt
@ 2019-11-18 14:28 ` Steven Rostedt
2019-11-18 15:24 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 12+ messages in thread
From: Steven Rostedt @ 2019-11-18 14:28 UTC (permalink / raw)
To: Hewenliang; +Cc: acme, tstoyanov, namhyung, linux-kernel, linfeilong
Arnaldo,
Can you take this patch?
Thanks!
-- Steve
On Fri, 25 Oct 2019 04:23:12 -0400
Hewenliang <hewenliang4@huawei.com> wrote:
> It is necessary to free the memory that we have allocated
> when error occurs.
>
> Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> Signed-off-by: Hewenliang <hewenliang4@huawei.com>
> ---
> tools/lib/traceevent/parse-filter.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> index 552592d153fb..fbaa790d10d8 100644
> --- a/tools/lib/traceevent/parse-filter.c
> +++ b/tools/lib/traceevent/parse-filter.c
> @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
> if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
> /* Add trivial event */
> arg = allocate_arg();
> - if (arg == NULL)
> + if (arg == NULL) {
> + free(str);
> return -1;
> + }
>
> arg->type = TEP_FILTER_ARG_BOOLEAN;
> if (strcmp(str, "TRUE") == 0)
> @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
> arg->boolean.value = 0;
>
> filter_type = add_filter_type(filter, event->id);
> - if (filter_type == NULL)
> + if (filter_type == NULL) {
> + free(str);
> + free(arg);
> return -1;
> + }
>
> filter_type->filter = arg;
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-11-18 14:28 ` [PATCH v2] tools lib traceevent: " Steven Rostedt
@ 2019-11-18 15:24 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-11-18 15:24 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Hewenliang, tstoyanov, namhyung, linux-kernel, linfeilong
Em Mon, Nov 18, 2019 at 09:28:44AM -0500, Steven Rostedt escreveu:
>
> Arnaldo,
>
> Can you take this patch?
Sure, taking this as an Acked-by you
> Thanks!
>
> -- Steve
>
>
> On Fri, 25 Oct 2019 04:23:12 -0400
> Hewenliang <hewenliang4@huawei.com> wrote:
>
> > It is necessary to free the memory that we have allocated
> > when error occurs.
> >
> > Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> > Signed-off-by: Hewenliang <hewenliang4@huawei.com>
> > ---
> > tools/lib/traceevent/parse-filter.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> > index 552592d153fb..fbaa790d10d8 100644
> > --- a/tools/lib/traceevent/parse-filter.c
> > +++ b/tools/lib/traceevent/parse-filter.c
> > @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
> > if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
> > /* Add trivial event */
> > arg = allocate_arg();
> > - if (arg == NULL)
> > + if (arg == NULL) {
> > + free(str);
> > return -1;
> > + }
> >
> > arg->type = TEP_FILTER_ARG_BOOLEAN;
> > if (strcmp(str, "TRUE") == 0)
> > @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
> > arg->boolean.value = 0;
> >
> > filter_type = add_filter_type(filter, event->id);
> > - if (filter_type == NULL)
> > + if (filter_type == NULL) {
> > + free(str);
> > + free(arg);
> > return -1;
> > + }
> >
> > filter_type->filter = arg;
> >
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-11-13 20:40 ` Steven Rostedt
2019-11-13 23:01 ` Arnaldo Carvalho de Melo
2019-11-18 3:42 ` Hewenliang
@ 2019-11-19 1:44 ` Hewenliang
2019-11-21 14:43 ` Arnaldo Carvalho de Melo
2019-11-23 8:15 ` [tip: perf/core] libtraceevent: " tip-bot2 for Hewenliang
2 siblings, 2 replies; 12+ messages in thread
From: Hewenliang @ 2019-11-19 1:44 UTC (permalink / raw)
To: rostedt, acme, tstoyanov, linux-kernel
It is necessary to free the memory that we have allocated when error occurs.
Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
Signed-off-by: Hewenliang <hewenliang4@huawei.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
tools/lib/traceevent/parse-filter.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 552592d153fb..f3cbf86e51ac 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
/* Add trivial event */
arg = allocate_arg();
- if (arg == NULL)
+ if (arg == NULL) {
+ free(str);
return -1;
+ }
arg->type = TEP_FILTER_ARG_BOOLEAN;
if (strcmp(str, "TRUE") == 0)
@@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
arg->boolean.value = 0;
filter_type = add_filter_type(filter, event->id);
- if (filter_type == NULL)
+ if (filter_type == NULL) {
+ free(str);
+ free_arg(arg);
return -1;
+ }
filter_type->filter = arg;
--
2.19.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2] tools lib traceevent: Fix memory leakage in copy_filter_type
2019-11-19 1:44 ` [PATCH v2] " Hewenliang
@ 2019-11-21 14:43 ` Arnaldo Carvalho de Melo
2019-11-23 8:15 ` [tip: perf/core] libtraceevent: " tip-bot2 for Hewenliang
1 sibling, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-11-21 14:43 UTC (permalink / raw)
To: Hewenliang; +Cc: rostedt, acme, tstoyanov, linux-kernel
Em Mon, Nov 18, 2019 at 08:44:15PM -0500, Hewenliang escreveu:
> It is necessary to free the memory that we have allocated when error occurs.
>
> Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
> Signed-off-by: Hewenliang <hewenliang4@huawei.com>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Thanks, applied.
- Arnaldo
> ---
> tools/lib/traceevent/parse-filter.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
> index 552592d153fb..f3cbf86e51ac 100644
> --- a/tools/lib/traceevent/parse-filter.c
> +++ b/tools/lib/traceevent/parse-filter.c
> @@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
> if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
> /* Add trivial event */
> arg = allocate_arg();
> - if (arg == NULL)
> + if (arg == NULL) {
> + free(str);
> return -1;
> + }
>
> arg->type = TEP_FILTER_ARG_BOOLEAN;
> if (strcmp(str, "TRUE") == 0)
> @@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
> arg->boolean.value = 0;
>
> filter_type = add_filter_type(filter, event->id);
> - if (filter_type == NULL)
> + if (filter_type == NULL) {
> + free(str);
> + free_arg(arg);
> return -1;
> + }
>
> filter_type->filter = arg;
>
> --
> 2.19.1
--
- Arnaldo
^ permalink raw reply [flat|nested] 12+ messages in thread
* [tip: perf/core] libtraceevent: Fix memory leakage in copy_filter_type
2019-11-19 1:44 ` [PATCH v2] " Hewenliang
2019-11-21 14:43 ` Arnaldo Carvalho de Melo
@ 2019-11-23 8:15 ` tip-bot2 for Hewenliang
1 sibling, 0 replies; 12+ messages in thread
From: tip-bot2 for Hewenliang @ 2019-11-23 8:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Hewenliang, Steven Rostedt (VMware), Tzvetomir Stoyanov,
Arnaldo Carvalho de Melo, x86, LKML
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 10992af6bf46a2048ad964985a5b77464e5563b1
Gitweb: https://git.kernel.org/tip/10992af6bf46a2048ad964985a5b77464e5563b1
Author: Hewenliang <hewenliang4@huawei.com>
AuthorDate: Mon, 18 Nov 2019 20:44:15 -05:00
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Fri, 22 Nov 2019 10:48:14 -03:00
libtraceevent: Fix memory leakage in copy_filter_type
It is necessary to free the memory that we have allocated when error occurs.
Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
Signed-off-by: Hewenliang <hewenliang4@huawei.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Link: http://lore.kernel.org/lkml/20191119014415.57210-1-hewenliang4@huawei.com
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/parse-filter.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 552592d..f3cbf86 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1473,8 +1473,10 @@ static int copy_filter_type(struct tep_event_filter *filter,
if (strcmp(str, "TRUE") == 0 || strcmp(str, "FALSE") == 0) {
/* Add trivial event */
arg = allocate_arg();
- if (arg == NULL)
+ if (arg == NULL) {
+ free(str);
return -1;
+ }
arg->type = TEP_FILTER_ARG_BOOLEAN;
if (strcmp(str, "TRUE") == 0)
@@ -1483,8 +1485,11 @@ static int copy_filter_type(struct tep_event_filter *filter,
arg->boolean.value = 0;
filter_type = add_filter_type(filter, event->id);
- if (filter_type == NULL)
+ if (filter_type == NULL) {
+ free(str);
+ free_arg(arg);
return -1;
+ }
filter_type->filter = arg;
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-11-23 8:15 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-25 8:23 [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type Hewenliang
2019-11-13 19:46 ` Steven Rostedt
2019-11-13 19:47 ` Steven Rostedt
2019-11-13 20:37 ` Arnaldo Carvalho de Melo
2019-11-13 20:40 ` Steven Rostedt
2019-11-13 23:01 ` Arnaldo Carvalho de Melo
2019-11-18 3:42 ` Hewenliang
2019-11-19 1:44 ` [PATCH v2] " Hewenliang
2019-11-21 14:43 ` Arnaldo Carvalho de Melo
2019-11-23 8:15 ` [tip: perf/core] libtraceevent: " tip-bot2 for Hewenliang
2019-11-18 14:28 ` [PATCH v2] tools lib traceevent: " Steven Rostedt
2019-11-18 15:24 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.