Skip to content

Commit c817cb5

Browse files
lhyang8gregkh
authored andcommitted
i40e: use the safe hash table iterator when deleting mac filters
[ Upstream commit 784548c ] This patch replaces hash_for_each function with hash_for_each_safe when calling __i40e_del_filter. The hash_for_each_safe function is the right one to use when iterating over a hash table to safely remove a hash entry. Otherwise, incorrect values may be read from freed memory. Detected by CoverityScan, CID 1402048 Read from pointer after free Signed-off-by: Lihong Yang <lihong.yang@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 66efe26 commit c817cb5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2779,6 +2779,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
27792779
struct i40e_mac_filter *f;
27802780
struct i40e_vf *vf;
27812781
int ret = 0;
2782+
struct hlist_node *h;
27822783
int bkt;
27832784

27842785
/* validate the request */
@@ -2817,7 +2818,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
28172818
/* Delete all the filters for this VSI - we're going to kill it
28182819
* anyway.
28192820
*/
2820-
hash_for_each(vsi->mac_filter_hash, bkt, f, hlist)
2821+
hash_for_each_safe(vsi->mac_filter_hash, bkt, h, f, hlist)
28212822
__i40e_del_filter(vsi, f);
28222823

28232824
spin_unlock_bh(&vsi->mac_filter_hash_lock);

0 commit comments

Comments
 (0)