net/dpaa2: Avoid explicit cpumask var allocation on stack
[ Upstream commit d33fe1714a44ff540629b149d8fab4ac6967585c ] For CONFIG_CPUMASK_OFFSTACK=y kernel, explicit allocation of cpumask variable on stack is not recommended since it can cause potential stack overflow. Instead, kernel code should always use *cpumask_var API(s) to allocate cpumask var in config-neutral way, leaving allocation strategy to CONFIG_CPUMASK_OFFSTACK. Use *cpumask_var API(s) to address it. Signed-off-by: Dawei Li <dawei.li@shingroup.cn> Link: https://lore.kernel.org/r/20240331053441.1276826-3-dawei.li@shingroup.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
d2cb4ae469
commit
0286651a80
1 changed files with 9 additions and 5 deletions
|
@ -2383,11 +2383,14 @@ static int dpaa2_eth_xdp_xmit(struct net_device *net_dev, int n,
|
||||||
static int update_xps(struct dpaa2_eth_priv *priv)
|
static int update_xps(struct dpaa2_eth_priv *priv)
|
||||||
{
|
{
|
||||||
struct net_device *net_dev = priv->net_dev;
|
struct net_device *net_dev = priv->net_dev;
|
||||||
struct cpumask xps_mask;
|
|
||||||
struct dpaa2_eth_fq *fq;
|
|
||||||
int i, num_queues, netdev_queues;
|
int i, num_queues, netdev_queues;
|
||||||
|
struct dpaa2_eth_fq *fq;
|
||||||
|
cpumask_var_t xps_mask;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
if (!alloc_cpumask_var(&xps_mask, GFP_KERNEL))
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
num_queues = dpaa2_eth_queue_count(priv);
|
num_queues = dpaa2_eth_queue_count(priv);
|
||||||
netdev_queues = (net_dev->num_tc ? : 1) * num_queues;
|
netdev_queues = (net_dev->num_tc ? : 1) * num_queues;
|
||||||
|
|
||||||
|
@ -2397,16 +2400,17 @@ static int update_xps(struct dpaa2_eth_priv *priv)
|
||||||
for (i = 0; i < netdev_queues; i++) {
|
for (i = 0; i < netdev_queues; i++) {
|
||||||
fq = &priv->fq[i % num_queues];
|
fq = &priv->fq[i % num_queues];
|
||||||
|
|
||||||
cpumask_clear(&xps_mask);
|
cpumask_clear(xps_mask);
|
||||||
cpumask_set_cpu(fq->target_cpu, &xps_mask);
|
cpumask_set_cpu(fq->target_cpu, xps_mask);
|
||||||
|
|
||||||
err = netif_set_xps_queue(net_dev, &xps_mask, i);
|
err = netif_set_xps_queue(net_dev, xps_mask, i);
|
||||||
if (err) {
|
if (err) {
|
||||||
netdev_warn_once(net_dev, "Error setting XPS queue\n");
|
netdev_warn_once(net_dev, "Error setting XPS queue\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_cpumask_var(xps_mask);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue