From bfd50c812fdd7aa6dd8e1e06188a5e288017ff04 Mon Sep 17 00:00:00 2001 From: Jiantao Xiao Date: Thu, 1 Jun 2023 19:40:57 +0800 Subject: [PATCH 240/283] net: hns3: fix set cpu affinity when state down driver inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8EN49 CVE: NA ---------------------------------------------------------------------- The CPU affinity can be configured when the network port is down. The patch fixes the problem. Signed-off-by: Jiantao Xiao (cherry picked from commit b2b62276a1f2ee4854d1ae8627161c50cda895a9) Signed-off-by: Xiaodong Li --- drivers/net/ethernet/hisilicon/hns3/hns3_ext.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c index 39bd51e93ddb..168c9c903158 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c @@ -139,6 +139,13 @@ int nic_set_cpu_affinity(struct net_device *ndev, cpumask_t *affinity_mask) goto err_unlock; } + if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) { + netdev_err(ndev, + "ethernet is down, not support cpu affinity set\n"); + ret = -ENETDOWN; + goto err_unlock; + } + for (i = 0; i < priv->vector_num; i++) { tqp_vector = &priv->tqp_vector[i]; if (tqp_vector->irq_init_flag != HNS3_VECTOR_INITED) -- 2.34.1