Skip to content

Commit 11fece4

Browse files
devnexenhtejun
authored andcommitted
tools/sched_ext: scx_flatcg: zero-initialize stats counter array
The local cnts array in read_stats() is not initialized before being accumulated into per-CPU stats, which may lead to reading garbage values. Zero it out with memset alongside the existing stats array initialization. Signed-off-by: David Carlier <devnexen@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 37a93dd commit 11fece4

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

tools/sched_ext/scx_flatcg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static void fcg_read_stats(struct scx_flatcg *skel, __u64 *stats)
106106
__u32 idx;
107107

108108
memset(stats, 0, sizeof(stats[0]) * FCG_NR_STATS);
109+
memset(cnts, 0, sizeof(cnts));
109110

110111
for (idx = 0; idx < FCG_NR_STATS; idx++) {
111112
int ret, cpu;

0 commit comments

Comments
 (0)