linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] tools libtraceevent fixes
@ 2022-05-13  2:33 Wang ShaoBo
  2022-05-13  2:33 ` [PATCH 1/2] libtraceevent: fix memleak in make_bprint_args() Wang ShaoBo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Wang ShaoBo @ 2022-05-13  2:33 UTC (permalink / raw)
  Cc: bobo.shaobowang, cj.chengjian, linux-kernel, liwei391, mhiramat,
	rostedt, acme, yuehaibing

tools libtraceevent fixes

Wang ShaoBo (2):
  libtraceevent: fix memleak in make_bprint_args()
  libtraceevent: fix free NULL pointer in parse_arg_add()

 tools/lib/traceevent/event-parse.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] libtraceevent: fix memleak in make_bprint_args()
  2022-05-13  2:33 [PATCH 0/2] tools libtraceevent fixes Wang ShaoBo
@ 2022-05-13  2:33 ` Wang ShaoBo
  2022-06-17 21:47   ` Steven Rostedt
  2022-05-13  2:33 ` [PATCH 2/2] libtraceevent: fix free NULL pointer in parse_arg_add() Wang ShaoBo
  2022-05-25  1:34 ` [PATCH 0/2] tools libtraceevent fixes Steven Rostedt
  2 siblings, 1 reply; 6+ messages in thread
From: Wang ShaoBo @ 2022-05-13  2:33 UTC (permalink / raw)
  Cc: bobo.shaobowang, cj.chengjian, linux-kernel, liwei391, mhiramat,
	rostedt, acme, yuehaibing

Release arg allocated from alloc_arg() when strdup failed in make_bprint_args().

Fixes: a6d2a61ac653 ("tools lib traceevent: Remove some die() calls")
Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
---
 tools/lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 8e24c4c78c7f..69e4d5229362 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4507,8 +4507,10 @@ static struct tep_print_arg *make_bprint_args(char *fmt, void *data, int size, s
 				arg->next = NULL;
 				arg->type = TEP_PRINT_BSTRING;
 				arg->string.string = strdup(bptr);
-				if (!arg->string.string)
+				if (!arg->string.string) {
+					free(arg);
 					goto out_free;
+				}
 				bptr += strlen(bptr) + 1;
 				*next = arg;
 				next = &arg->next;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] libtraceevent: fix free NULL pointer in parse_arg_add()
  2022-05-13  2:33 [PATCH 0/2] tools libtraceevent fixes Wang ShaoBo
  2022-05-13  2:33 ` [PATCH 1/2] libtraceevent: fix memleak in make_bprint_args() Wang ShaoBo
@ 2022-05-13  2:33 ` Wang ShaoBo
  2022-06-17 21:44   ` Steven Rostedt
  2022-05-25  1:34 ` [PATCH 0/2] tools libtraceevent fixes Steven Rostedt
  2 siblings, 1 reply; 6+ messages in thread
From: Wang ShaoBo @ 2022-05-13  2:33 UTC (permalink / raw)
  Cc: bobo.shaobowang, cj.chengjian, linux-kernel, liwei391, mhiramat,
	rostedt, acme, yuehaibing

Should not call free if parg->format is NULL.

Fixes: e7a90882b05b ("tools lib traceevent: Optimize pretty_print() function")
Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
---
 tools/lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 69e4d5229362..b1a07db54457 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5461,9 +5461,11 @@ static int parse_arg_add(struct tep_print_parse **parse, char *format,
 	return 0;
 error:
 	if (parg) {
-		free(parg->format);
+		if (parg->format)
+			free(parg->format);
 		free(parg);
 	}
+
 	return -1;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] tools libtraceevent fixes
  2022-05-13  2:33 [PATCH 0/2] tools libtraceevent fixes Wang ShaoBo
  2022-05-13  2:33 ` [PATCH 1/2] libtraceevent: fix memleak in make_bprint_args() Wang ShaoBo
  2022-05-13  2:33 ` [PATCH 2/2] libtraceevent: fix free NULL pointer in parse_arg_add() Wang ShaoBo
@ 2022-05-25  1:34 ` Steven Rostedt
  2 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2022-05-25  1:34 UTC (permalink / raw)
  To: Wang ShaoBo
  Cc: cj.chengjian, linux-kernel, liwei391, mhiramat, acme, yuehaibing

On Fri, 13 May 2022 10:33:06 +0800
Wang ShaoBo <bobo.shaobowang@huawei.com> wrote:

> tools libtraceevent fixes
> 
> Wang ShaoBo (2):
>   libtraceevent: fix memleak in make_bprint_args()
>   libtraceevent: fix free NULL pointer in parse_arg_add()

These fixes need to be sent to linux-trace-devel@vger.kernel.org, and
applied against libtraceevent:

  https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/

Arnaldo,

libtraceevent is now in most distros. Can we now deprecate the version in
the kernel as it is no longer actively maintained?

-- Steve


> 
>  tools/lib/traceevent/event-parse.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] libtraceevent: fix free NULL pointer in parse_arg_add()
  2022-05-13  2:33 ` [PATCH 2/2] libtraceevent: fix free NULL pointer in parse_arg_add() Wang ShaoBo
@ 2022-06-17 21:44   ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2022-06-17 21:44 UTC (permalink / raw)
  To: Wang ShaoBo
  Cc: cj.chengjian, linux-kernel, liwei391, mhiramat, acme, yuehaibing

On Fri, 13 May 2022 10:33:08 +0800
Wang ShaoBo <bobo.shaobowang@huawei.com> wrote:

> Should not call free if parg->format is NULL.
> 
> Fixes: e7a90882b05b ("tools lib traceevent: Optimize pretty_print() function")
> Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
> ---
>  tools/lib/traceevent/event-parse.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index 69e4d5229362..b1a07db54457 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -5461,9 +5461,11 @@ static int parse_arg_add(struct tep_print_parse **parse, char *format,
>  	return 0;
>  error:
>  	if (parg) {
> -		free(parg->format);
> +		if (parg->format)
> +			free(parg->format);

It's perfectly fine to call free(NULL).

This is not a bug fix.

-- Steve

>  		free(parg);
>  	}
> +
>  	return -1;
>  }
>  


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] libtraceevent: fix memleak in make_bprint_args()
  2022-05-13  2:33 ` [PATCH 1/2] libtraceevent: fix memleak in make_bprint_args() Wang ShaoBo
@ 2022-06-17 21:47   ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2022-06-17 21:47 UTC (permalink / raw)
  To: Wang ShaoBo
  Cc: cj.chengjian, linux-kernel, liwei391, mhiramat, acme, yuehaibing

On Fri, 13 May 2022 10:33:07 +0800
Wang ShaoBo <bobo.shaobowang@huawei.com> wrote:

> Release arg allocated from alloc_arg() when strdup failed in make_bprint_args().
> 
> Fixes: a6d2a61ac653 ("tools lib traceevent: Remove some die() calls")
> Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
> ---
>  tools/lib/traceevent/event-parse.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index 8e24c4c78c7f..69e4d5229362 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -4507,8 +4507,10 @@ static struct tep_print_arg *make_bprint_args(char *fmt, void *data, int size, s
>  				arg->next = NULL;
>  				arg->type = TEP_PRINT_BSTRING;
>  				arg->string.string = strdup(bptr);
> -				if (!arg->string.string)
> +				if (!arg->string.string) {
> +					free(arg);
>  					goto out_free;

This is a fix, thank you. But libtraceevent now lives here:

  https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/

I'll port this patch to that.

Thanks,

-- Steve

> +				}
>  				bptr += strlen(bptr) + 1;
>  				*next = arg;
>  				next = &arg->next;


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-17 21:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13  2:33 [PATCH 0/2] tools libtraceevent fixes Wang ShaoBo
2022-05-13  2:33 ` [PATCH 1/2] libtraceevent: fix memleak in make_bprint_args() Wang ShaoBo
2022-06-17 21:47   ` Steven Rostedt
2022-05-13  2:33 ` [PATCH 2/2] libtraceevent: fix free NULL pointer in parse_arg_add() Wang ShaoBo
2022-06-17 21:44   ` Steven Rostedt
2022-05-25  1:34 ` [PATCH 0/2] tools libtraceevent fixes Steven Rostedt

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).