Skip to content

Commit 8cd5fe6

Browse files
Paweł JabłońskiJeff Kirsher
authored andcommitted
i40evf: Fix double locking the same resource
Removes the locking of adapter->mac_vlan_list_lock resource in i40evf_add_filter(). The locking part is moved above i40evf_add_filter(). i40evf_add_filter(), called by i40evf_addr_sync(), was trying to lock the resource again and double locking generated a kernel panic after bringing an interface up. Fixes: 8946b56 ("i40evf: use __dev_[um]c_sync routines in .set_rx_mode") Signed-off-by: Paweł Jabłoński <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent c3880bd commit 8cd5fe6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/net/ethernet/intel/i40evf/i40evf_main.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -815,13 +815,11 @@ i40evf_mac_filter *i40evf_add_filter(struct i40evf_adapter *adapter,
815815
if (!macaddr)
816816
return NULL;
817817

818-
spin_lock_bh(&adapter->mac_vlan_list_lock);
819-
820818
f = i40evf_find_filter(adapter, macaddr);
821819
if (!f) {
822820
f = kzalloc(sizeof(*f), GFP_ATOMIC);
823821
if (!f)
824-
goto clearout;
822+
return f;
825823

826824
ether_addr_copy(f->macaddr, macaddr);
827825

@@ -832,8 +830,6 @@ i40evf_mac_filter *i40evf_add_filter(struct i40evf_adapter *adapter,
832830
f->remove = false;
833831
}
834832

835-
clearout:
836-
spin_unlock_bh(&adapter->mac_vlan_list_lock);
837833
return f;
838834
}
839835

@@ -868,9 +864,10 @@ static int i40evf_set_mac(struct net_device *netdev, void *p)
868864
adapter->aq_required |= I40EVF_FLAG_AQ_DEL_MAC_FILTER;
869865
}
870866

867+
f = i40evf_add_filter(adapter, addr->sa_data);
868+
871869
spin_unlock_bh(&adapter->mac_vlan_list_lock);
872870

873-
f = i40evf_add_filter(adapter, addr->sa_data);
874871
if (f) {
875872
ether_addr_copy(hw->mac.addr, addr->sa_data);
876873
ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
@@ -3040,7 +3037,12 @@ static int i40evf_open(struct net_device *netdev)
30403037
if (err)
30413038
goto err_req_irq;
30423039

3040+
spin_lock_bh(&adapter->mac_vlan_list_lock);
3041+
30433042
i40evf_add_filter(adapter, adapter->hw.mac.addr);
3043+
3044+
spin_unlock_bh(&adapter->mac_vlan_list_lock);
3045+
30443046
i40evf_configure(adapter);
30453047

30463048
i40evf_up_complete(adapter);

0 commit comments

Comments
 (0)