From: Yang Jihong Date: Fri, 19 Jan 2024 04:03:02 +0000 (+0000) Subject: perf record: Fix possible incorrect free in record__switch_output() X-Git-Tag: v5.10.214~111 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7007354d0caf126a49891e60a9477963d6b3bb01;p=thirdparty%2Fkernel%2Fstable.git perf record: Fix possible incorrect free in record__switch_output() [ Upstream commit aff10a165201f6f60cff225083ce301ad3f5d8f1 ] perf_data__switch() may not assign a legal value to 'new_filename'. In this case, 'new_filename' uses the on-stack value, which may cause a incorrect free and unexpected result. Fixes: 03724b2e9c45 ("perf record: Allow to limit number of reported perf.data files") Signed-off-by: Yang Jihong Acked-by: Namhyung Kim Link: https://lore.kernel.org/r/20240119040304.3708522-2-yangjihong1@huawei.com Signed-off-by: Namhyung Kim Signed-off-by: Sasha Levin --- diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index e5c938d538ee5..167cd8d3b7a21 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1264,8 +1264,8 @@ static int record__switch_output(struct record *rec, bool at_exit) { struct perf_data *data = &rec->data; + char *new_filename = NULL; int fd, err; - char *new_filename; /* Same Size: "2015122520103046"*/ char timestamp[] = "InvalidTimestamp";