Re: [PATCH net v2] net: stmmac: Fix accessing freed irq affinity_hint

From: Jakub Kicinski
Date: Mon Mar 24 2025 - 14:36:43 EST


On Tue, 18 Mar 2025 11:24:23 +0800 Qingfang Deng wrote:
> - cpumask_clear(&cpu_mask);
> - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask);
> - irq_set_affinity_hint(priv->rx_irq[i], &cpu_mask);
> + irq_set_affinity_hint(priv->rx_irq[i],
> + cpumask_of(i % num_online_cpus()));

This does fix the bug you're targeting, but FWIW num_online_cpus()
is not great in general. The online CPU mask can be sparse.
You may want to look into finding 'nth' online CPU instead of the naive
modulo as a follow up.