tools/proftool: fix use-after-free
authorVincent Stehlé <vincent.stehle@freescale.com>
Wed, 7 Oct 2015 13:48:48 +0000 (15:48 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 16 Nov 2015 22:22:18 +0000 (17:22 -0500)
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é <vincent.stehle@freescale.com>
Cc: Simon Glass <sjg@chromium.org>
tools/proftool.c

index 9ce7a7796e7f04b310eae4dc713d6c6a613e0acb..ddf870f66ee7d732a0338e28fb429185476b78b0 100644 (file)
@@ -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 */