[PATCH] libtraceevent: Fix memleak in make_bprint_args()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wang ShaoBo <bobo.shaobowang@xxxxxxxxxx>

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

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

Fixes: 8b43424c32702 ("tools lib traceevent: Remove some die() calls")
Signed-off-by: Wang ShaoBo <bobo.shaobowang@xxxxxxxxxx>
Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux