All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libtraceevent: Fix memleak in make_bprint_args()
@ 2022-06-17 21:51 Steven Rostedt
  0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2022-06-17 21:51 UTC (permalink / raw)
  To: Linux Trace Devel; +Cc: Wang ShaoBo

From: Wang ShaoBo <bobo.shaobowang@huawei.com>

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

Link: https://lkml.kernel.org/r/20220513023308.2400381-2-bobo.shaobowang@huawei.com

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

diff --git a/src/event-parse.c b/src/event-parse.c
index 1ba2a78d20a9..4bbf29727e9f 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -4915,8 +4915,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.35.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-17 21:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 21:51 [PATCH] libtraceevent: Fix memleak in make_bprint_args() Steven Rostedt

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.