Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf sched: Fix resource leak in enable_sched_schedstats()
@ 2026-09-03  8:21 liujing
  2026-09-03  8:21 ` [PATCH] perf intel-pt: Fix undefined shift in intel_pt_bip() liujing
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: liujing @ 2026-09-03  8:21 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim
  Cc: Ian Rogers, linux-perf-users, linux-kernel, Liu Jing

From: Liu Jing <liujing@cmss.chinamobile.com>

In enable_sched_schedstats(), the FILE pointer fp is only closed when
ch == '0'. If ch is not '0' (i.e., sched_schedstats is already enabled),
the function returns 0 without calling fclose(fp), causing a resource
leak.

Fix it by adding fclose(fp) before the return statement.

Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
---
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -4114,8 +4114,8 @@
 		*reset = 1;
 		rewind(fp);
 		putc('1', fp);
-		fclose(fp);
-	}
+	}
+	fclose(fp);
 	return 0;
 }
 





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-09-03  8:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03  8:21 [PATCH] perf sched: Fix resource leak in enable_sched_schedstats() liujing
2026-09-03  8:21 ` [PATCH] perf intel-pt: Fix undefined shift in intel_pt_bip() liujing
2026-09-03  8:31   ` sashiko-bot
2026-09-03  8:21 ` [PATCH] perf script: Fix unsigned comparison against zero in print_bstack_flags() liujing
2026-09-03  8:26   ` sashiko-bot
2026-09-03  8:21 ` [PATCH] perf arm: Fix memory leak in find_all_arm_spe_pmus() liujing
2026-09-03  8:31   ` sashiko-bot
2026-09-03  8:33 ` [PATCH] perf sched: Fix resource leak in enable_sched_schedstats() sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox