Re: [PATCH] workqueue: validate cpumask_first() result in llc_populate_cpu_shard_id()
From: Breno Leitao
Date: Mon Apr 13 2026 - 10:29:09 EST
On Fri, Apr 10, 2026 at 07:36:10AM -1000, Tejun Heo wrote:
> Hello,
>
> On Fri, Apr 10, 2026 at 03:42:00AM -0700, Breno Leitao wrote:
> > @@ -8318,7 +8319,17 @@ static void __init llc_populate_cpu_shard_id(const struct cpumask *pod_cpus,
> > * The siblings' shard MUST be the same as the leader.
> > * never split threads in the same core.
> > */
> > - cpu_shard_id[c] = cpu_shard_id[cpumask_first(sibling_cpus)];
> > + leader = cpumask_first(sibling_cpus);
> > +
> > + /*
> > + * sibling_cpus cannot be empty here since 'c'
> > + * is always set in it. This check silences a
> > + * compiler warning about using the unchecked
> > + * cpumask_first() result as an array index.
> > + */
>
> Can you add more details on the warning and update the patch desc
> accordingly?
Ack!
> This only triggers on UP configs, right?
yes, this only triggers on UP configs (like nios2) because on SMP
NR_CPUS > 1 and the compiler can't prove the index is out of bounds.