Skip to contentSkip to conversation

tools: proftool: Fix potential memory leaks

PATCH In review Maks Mishin 2 participants 2 messages Feb 5, 2025 – Feb 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: proftool: Fix potential memory leaks

Dynamic memory, referenced by 'line', is allocated by calling function 'calloc' and lost when the function terminates with code -1.

---
 tools/proftool.c | 3 +++
 1 file changed, 3 insertions(+)
tools/proftool.c +3 -0
index af2cdb6d58..c7b427f307 100644
@@ -676,6 +676,7 @@ static int read_trace_config(FILE *fin)
 		if (!tok) {
 			error("Invalid trace config data on line %d\n",
 			      linenum);
+			free(line);
 			return -1;
 		}
 		if (0 == strcmp(tok, "include-func")) {
@@ -685,6 +686,7 @@ static int read_trace_config(FILE *fin)
 		} else {
 			error("Unknown command in trace config data line %d\n",
 			      linenum);
+			free(line);
 			return -1;
 		}
 
@@ -692,6 +694,7 @@ static int read_trace_config(FILE *fin)
 		if (!tok) {
 			error("Missing pattern in trace config data line %d\n",
 			      linenum);
+			free(line);
 			return -1;
 		}
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 4 lines · Maks Mishin

Dynamic memory, referenced by 'line', is allocated by calling function 'calloc' and lost when the function terminates with code -1.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom