From 1ca8f8818ba82d7d62cf87dfa3f45e011da62526 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vincent=20Stehl=C3=A9?= Date: Wed, 7 Oct 2015 15:48:48 +0200 Subject: [PATCH] tools/proftool: fix use-after-free MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The read_trace_config() can dereference the line pointer after freeing it on its error path. Avoid that. This was found by Coverity Scan. Signed-off-by: Vincent Stehlé Cc: Simon Glass --- tools/proftool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/proftool.c b/tools/proftool.c index 9ce7a77..ddf870f 100644 --- a/tools/proftool.c +++ b/tools/proftool.c @@ -432,9 +432,10 @@ static int read_trace_config(FILE *fin) err = regcomp(&line->regex, tok, REG_NOSUB); if (err) { + int r = regex_report_error(&line->regex, err, + "compile", tok); free(line); - return regex_report_error(&line->regex, err, "compile", - tok); + return r; } /* link this new one to the end of the list */ -- 2.7.4