From: Ian Rogers Date: Mon, 9 Oct 2023 18:39:18 +0000 (-0700) Subject: perf trace-event-info: Avoid passing NULL value to closedir X-Git-Tag: v6.7-rc1~83^2~65 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=97fe038374bdf43fd025ac0e7aebf8bfbdd6d54f;p=thirdparty%2Fkernel%2Fstable.git perf trace-event-info: Avoid passing NULL value to closedir If opendir failed then closedir was passed NULL which is erroneous. Caught by clang-tidy. Signed-off-by: Ian Rogers Acked-by: Namhyung Kim Cc: Ravi Bangoria Cc: Nick Desaulniers Cc: Yang Jihong Cc: Huacai Chen Cc: Nathan Chancellor Cc: Kan Liang Cc: llvm@lists.linux.dev Cc: Ming Wang Cc: Tom Rix Cc: bpf@vger.kernel.org Link: https://lore.kernel.org/r/20231009183920.200859-18-irogers@google.com Signed-off-by: Namhyung Kim --- diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 319ccf09a4351..c8755679281eb 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c @@ -313,7 +313,8 @@ static int record_event_files(struct tracepoint_path *tps) } err = 0; out: - closedir(dir); + if (dir) + closedir(dir); put_tracing_file(path); return err;