aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLihong Yang <lihong.yang@intel.com>2019-06-05 15:45:16 -0400
committerDavid S. Miller <davem@davemloft.net>2019-06-05 19:53:25 -0400
commit80598e6230c7091e8377e97dc8678ca06a936f2a (patch)
tree1ae1ea308582392d5ea3cac3b7bba9b680ff2f64
parent745b32c1a3faddbc5b96aade83c677454401f2e6 (diff)
i40e: Check and set the PF driver state first in i40e_ndo_set_vf_mac
The PF driver state flag __I40E_VIRTCHNL_OP_PENDING needs to be checked and set at the beginning of i40e_ndo_set_vf_mac. Otherwise, if there are error conditions before it, the flag will be cleared unexpectedly by this function to cause potential race conditions. Hence move the check to the top of this function. Signed-off-by: Lihong Yang <lihong.yang@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index f14367834318..09a7fd4d24e8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -3943,6 +3943,11 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
3943 int bkt; 3943 int bkt;
3944 u8 i; 3944 u8 i;
3945 3945
3946 if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {
3947 dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n");
3948 return -EAGAIN;
3949 }
3950
3946 /* validate the request */ 3951 /* validate the request */
3947 ret = i40e_validate_vf(pf, vf_id); 3952 ret = i40e_validate_vf(pf, vf_id);
3948 if (ret) 3953 if (ret)
@@ -3967,11 +3972,6 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
3967 goto error_param; 3972 goto error_param;
3968 } 3973 }
3969 3974
3970 if (test_and_set_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state)) {
3971 dev_warn(&pf->pdev->dev, "Unable to configure VFs, other operation is pending.\n");
3972 return -EAGAIN;
3973 }
3974
3975 if (is_multicast_ether_addr(mac)) { 3975 if (is_multicast_ether_addr(mac)) {
3976 dev_err(&pf->pdev->dev, 3976 dev_err(&pf->pdev->dev,
3977 "Invalid Ethernet address %pM for VF %d\n", mac, vf_id); 3977 "Invalid Ethernet address %pM for VF %d\n", mac, vf_id);