From f4b6eb2b91f38dc9ebc6c4e2b913fd1d25f14773 Mon Sep 17 00:00:00 2001 From: Wenwu Ma Date: Fri, 2 Apr 2021 13:52:47 +0000 Subject: [PATCH] net/ice: fix illegal access when removing MAC filter When removing the mac filter in ice_remove_all_mac_vlan_filters(), TAILQ_FOREACH_SAFE should be used instead of TAILQ_FOREACH, Otherwise, it will result in a illegal pointer access. Fixes: e0dcf94a0d7f ("net/ice: support VLAN ops") Cc: stable@dpdk.org Signed-off-by: Wenwu Ma Tested-by: Zhihong Peng Acked-by: Qi Zhang --- drivers/net/ice/ice_ethdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index a1365131e0..84d1735255 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -10,6 +10,8 @@ #include #include +#include + #include "base/ice_sched.h" #include "base/ice_flow.h" #include "base/ice_dcb.h" @@ -1092,12 +1094,13 @@ ice_remove_all_mac_vlan_filters(struct ice_vsi *vsi) { struct ice_mac_filter *m_f; struct ice_vlan_filter *v_f; + void *temp; int ret = 0; if (!vsi || !vsi->mac_num) return -EINVAL; - TAILQ_FOREACH(m_f, &vsi->mac_list, next) { + TAILQ_FOREACH_SAFE(m_f, &vsi->mac_list, next, temp) { ret = ice_remove_mac_filter(vsi, &m_f->mac_info.mac_addr); if (ret != ICE_SUCCESS) { ret = -EINVAL; @@ -1108,7 +1111,7 @@ ice_remove_all_mac_vlan_filters(struct ice_vsi *vsi) if (vsi->vlan_num == 0) return 0; - TAILQ_FOREACH(v_f, &vsi->vlan_list, next) { + TAILQ_FOREACH_SAFE(v_f, &vsi->vlan_list, next, temp) { ret = ice_remove_vlan_filter(vsi, &v_f->vlan_info.vlan); if (ret != ICE_SUCCESS) { ret = -EINVAL; -- 2.20.1