2019-10-25 19:31:35

by h00486469

[permalink] [raw]
Subject: [PATCH] tools lib traceevent: 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 <[email protected]>
---
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


2019-11-13 19:47:28

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type

On Fri, 25 Oct 2019 04:23:12 -0400
Hewenliang <[email protected]> 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 <[email protected]>

Reviewed-by: Steven Rostedt (VMware) <[email protected]>

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;
>

2019-11-13 19:49:03

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type

On Wed, 13 Nov 2019 14:46:26 -0500
Steven Rostedt <[email protected]> wrote:

> On Fri, 25 Oct 2019 04:23:12 -0400
> Hewenliang <[email protected]> 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 <[email protected]>
>
> Reviewed-by: Steven Rostedt (VMware) <[email protected]>

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;
> >
>

2019-11-13 20:40:43

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type

Em Wed, Nov 13, 2019 at 02:46:26PM -0500, Steven Rostedt escreveu:
> On Fri, 25 Oct 2019 04:23:12 -0400
> Hewenliang <[email protected]> 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 <[email protected]>
>
> Reviewed-by: Steven Rostedt (VMware) <[email protected]>
>
> 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;
> >

2019-11-13 20:42:44

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type

On Wed, 13 Nov 2019 18:37:10 -0200
Arnaldo Carvalho de Melo <[email protected]> wrote:

> Em Wed, Nov 13, 2019 at 02:46:26PM -0500, Steven Rostedt escreveu:
> > On Fri, 25 Oct 2019 04:23:12 -0400
> > Hewenliang <[email protected]> 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 <[email protected]>
> >
> > Reviewed-by: Steven Rostedt (VMware) <[email protected]>
> >
> > 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
>

2019-11-13 23:03:03

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] tools lib traceevent: Fix memory leakage in copy_filter_type

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 <[email protected]> wrote:
>
> > Em Wed, Nov 13, 2019 at 02:46:26PM -0500, Steven Rostedt escreveu:
> > > On Fri, 25 Oct 2019 04:23:12 -0400
> > > Hewenliang <[email protected]> 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 <[email protected]>
> > >
> > > Reviewed-by: Steven Rostedt (VMware) <[email protected]>
> > >
> > > 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
> >

2019-11-18 03:45:10

by h00486469

[permalink] [raw]
Subject: [PATCH] tools lib traceevent: 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 <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
Reviewed-by: Steven Rostedt (VMware) <[email protected]>
---
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

2019-11-18 14:32:57

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH v2] tools lib traceevent: Fix memory leakage in copy_filter_type


Arnaldo,

Can you take this patch?

Thanks!

-- Steve


On Fri, 25 Oct 2019 04:23:12 -0400
Hewenliang <[email protected]> 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 <[email protected]>
> ---
> 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;
>

2019-11-18 15:26:25

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH v2] tools lib traceevent: Fix memory leakage in copy_filter_type

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 <[email protected]> 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 <[email protected]>
> > ---
> > 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;
> >

2019-11-19 01:46:36

by h00486469

[permalink] [raw]
Subject: [PATCH v2] tools lib traceevent: 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 <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
Reviewed-by: Steven Rostedt (VMware) <[email protected]>
---
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

2019-11-21 14:46:43

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH v2] tools lib traceevent: Fix memory leakage in copy_filter_type

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 <[email protected]>
> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
> Reviewed-by: Steven Rostedt (VMware) <[email protected]>

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

Subject: [tip: perf/core] libtraceevent: Fix memory leakage in copy_filter_type

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 <[email protected]>
AuthorDate: Mon, 18 Nov 2019 20:44:15 -05:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
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 <[email protected]>
Reviewed-by: Steven Rostedt (VMware) <[email protected]>
Cc: Tzvetomir Stoyanov <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
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;