Skip to content

Commit 1b0b375

Browse files
committed
perf drm_pmu: Fix fd_dir leaks in for_each_drm_fdinfo_in_dir()
JIRA: https://issues.redhat.com/browse/RHEL-78200 upstream ======== commit baa0348 Author: GuoHan Zhao <zhaoguohan@kylinos.cn> Date: Mon Sep 8 14:52:03 2025 +0800 description =========== Fix file descriptor leak when callback function returns error. The function was directly returning without closing fdinfo_dir_fd and fd_dir when cb() returned non-zero value. Fixes: 28917cb ("perf drm_pmu: Add a tool like PMU to expose DRM information") Reviewed-by: Ian Rogers <irogers@google.com> Reviewed-by: Markus Elfring <Markus.Elfring@web.de> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20250908065203.22187-1-zhaoguohan@kylinos.cn Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
1 parent f9aa7c4 commit 1b0b375

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/perf/util/drm_pmu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,10 @@ static int for_each_drm_fdinfo_in_dir(int (*cb)(void *args, int fdinfo_dir_fd, c
458458
}
459459
ret = cb(args, fdinfo_dir_fd, fd_entry->d_name);
460460
if (ret)
461-
return ret;
461+
goto close_fdinfo;
462462
}
463+
464+
close_fdinfo:
463465
if (fdinfo_dir_fd != -1)
464466
close(fdinfo_dir_fd);
465467
closedir(fd_dir);

0 commit comments

Comments
 (0)