perf record: Fix possible incorrect free in record__switch_output()
authorYang Jihong <yangjihong1@huawei.com>
Fri, 19 Jan 2024 04:03:02 +0000 (04:03 +0000)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 22 Jan 2024 20:08:20 +0000 (12:08 -0800)
commitaff10a165201f6f60cff225083ce301ad3f5d8f1
tree024a383d6cc7ddd2b9fdc97497d98460958bed33
parent55442cc2f22d0727abfecc3a30c605f04acff4b7
perf record: Fix possible incorrect free in record__switch_output()

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 <yangjihong1@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240119040304.3708522-2-yangjihong1@huawei.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/builtin-record.c