* [PATCH] perf drm_pmu: fix fd_dir leaks in for_each_drm_fdinfo_in_dir()
@ 2025-08-12 6:35 zhaoguohan
2025-08-12 13:46 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: zhaoguohan @ 2025-08-12 6:35 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang
Cc: linux-perf-users, linux-kernel, GuoHan Zhao
From: GuoHan Zhao <zhaoguohan@kylinos.cn>
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.
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
---
tools/perf/util/drm_pmu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/drm_pmu.c b/tools/perf/util/drm_pmu.c
index 988890f37ba7..424a76d1a953 100644
--- a/tools/perf/util/drm_pmu.c
+++ b/tools/perf/util/drm_pmu.c
@@ -458,8 +458,10 @@ static int for_each_drm_fdinfo_in_dir(int (*cb)(void *args, int fdinfo_dir_fd, c
}
ret = cb(args, fdinfo_dir_fd, fd_entry->d_name);
if (ret)
- return ret;
+ goto cleanup;
}
+
+cleanup:
if (fdinfo_dir_fd != -1)
close(fdinfo_dir_fd);
closedir(fd_dir);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] perf drm_pmu: fix fd_dir leaks in for_each_drm_fdinfo_in_dir()
2025-08-12 6:35 [PATCH] perf drm_pmu: fix fd_dir leaks in for_each_drm_fdinfo_in_dir() zhaoguohan
@ 2025-08-12 13:46 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2025-08-12 13:46 UTC (permalink / raw)
To: GuoHan Zhao, linux-perf-users
Cc: LKML, Adrian Hunter, Alexander Shishkin,
Arnaldo Carvalho de Melo, Ian Rogers, Ingo Molnar, Jiri Olsa,
Kan Liang, Mark Rutland, Namhyung Kim, Peter Zijlstra
> Fix file descriptor leak when callback function returns error. …
How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
Regards,
Markus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-12 13:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-12 6:35 [PATCH] perf drm_pmu: fix fd_dir leaks in for_each_drm_fdinfo_in_dir() zhaoguohan
2025-08-12 13:46 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®