Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched_ext: fix application of sizeof to pointer

sizeof when applied to a pointer typed expression gives the size of
the pointer.

The proper fix in this particular case is to code sizeof(*cpuset)
instead of sizeof(cpuset).

This issue was detected with the help of Coccinelle.

Fixes: 22a920209ab6 ("sched_ext: Implement tickless support")
Signed-off-by: guanjing <guanjing@cmss.chinamobile.com>
Acked-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

guanjing and committed by
Tejun Heo
f24d1929 ef7009de

+1 -1
+1 -1
tools/sched_ext/scx_central.c
··· 97 97 SCX_BUG_ON(!cpuset, "Failed to allocate cpuset"); 98 98 CPU_ZERO(cpuset); 99 99 CPU_SET(skel->rodata->central_cpu, cpuset); 100 - SCX_BUG_ON(sched_setaffinity(0, sizeof(cpuset), cpuset), 100 + SCX_BUG_ON(sched_setaffinity(0, sizeof(*cpuset), cpuset), 101 101 "Failed to affinitize to central CPU %d (max %d)", 102 102 skel->rodata->central_cpu, skel->rodata->nr_cpu_ids - 1); 103 103 CPU_FREE(cpuset);