diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 8af8e7f55254aadb3a2829039ccdf5d64a384a4f..e2bf620f98cb29b6d5cc89010fa0fbdc8ce589bc 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -790,7 +790,11 @@ static int __show_line_range(struct line_range *lr, const char *module, /* Convert source file path */ tmp = lr->path; ret = get_real_path(tmp, lr->comp_dir, &lr->path); - free(tmp); /* Free old path */ + + /* Free old path when new path is assigned */ + if (tmp != lr->path) + free(tmp); + if (ret < 0) { pr_warning("Failed to find source file path.\n"); return ret;