]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf thread_map: Free strlist on normal path in thread_map__new_by_tid_str()
authorYang Jihong <yangjihong1@huawei.com>
Tue, 6 Feb 2024 08:32:28 +0000 (08:32 +0000)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 9 Feb 2024 22:08:41 +0000 (14:08 -0800)
slist needs to be freed in both error path and normal path in
thread_map__new_by_tid_str().

Fixes: b52956c961be3a04 ("perf tools: Allow multiple threads or processes in record, stat, top")
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240206083228.172607-6-yangjihong1@huawei.com
tools/perf/util/thread_map.c

index e848579e61a86330856a8cb2ae8f7c8564bfd5c5..ea3b431b978301edcbc35c867c05ad8ce6ff697e 100644 (file)
@@ -280,13 +280,13 @@ struct perf_thread_map *thread_map__new_by_tid_str(const char *tid_str)
                threads->nr = ntasks;
        }
 out:
+       strlist__delete(slist);
        if (threads)
                refcount_set(&threads->refcnt, 1);
        return threads;
 
 out_free_threads:
        zfree(&threads);
-       strlist__delete(slist);
        goto out;
 }