Skip to contentSkip to conversation

trace-cmd: free kbuf on malloc err in tracecmd_read_page_record()

PATCH Applied Marcelo Diop-Gonzalez 2 participants 2 messages Jan 15, 2020 – Jan 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd: free kbuf on malloc err in tracecmd_read_page_record()

This fixes an unlikely but possible leak

---
 lib/trace-cmd/trace-input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/trace-cmd/trace-input.c +1 -1
index ac30a60..68da3a7 100644
@@ -1746,7 +1746,7 @@ tracecmd_read_page_record(struct tep_handle *pevent, void *page, int size,
 
 	record = malloc(sizeof(*record));
 	if (!record)
-		return NULL;
+		goto out_free;
 	memset(record, 0, sizeof(*record));
 
 	record->ts = ts;
Signature · 1 line
2.25.0.rc1.283.g88dfdc4193-goog
#1 lore raw
Quoted 1 line · On Wed, 15 Jan 2020 15:05:15 -0500 Marcelo Diop-Gonzalez…

This fixes an unlikely but possible leak

Applied, thanks Marcelo!

-- Steve

Quoted 19 lines
---
 lib/trace-cmd/trace-input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/trace-cmd/trace-input.c +1 -1
index ac30a60..68da3a7 100644
@@ -1746,7 +1746,7 @@ tracecmd_read_page_record(struct tep_handle *pevent, void *page, int size,
 
 	record = malloc(sizeof(*record));
 	if (!record)
-		return NULL;
+		goto out_free;
 	memset(record, 0, sizeof(*record));
 
 	record->ts = ts;