Re: [PATCH 4/6] staging: rtl8188eu: use safe iterator in rtw_acl_remove_sta

From: Guenter Roeck
Date: Sun May 16 2021 - 15:24:47 EST


On Sun, May 16, 2021 at 06:06:11PM +0200, Martin Kaiser wrote:
> Use list_for_each_safe, we may delete list items while iterating over
> the list.
>
> Fixes: 23017c8842d2 ("staging: rtl8188eu: Use list iterators and helpers")
> Signed-off-by: Martin Kaiser <martin@xxxxxxxxx>

Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>

> ---
> compile-tested only
>
> drivers/staging/rtl8188eu/core/rtw_ap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
> index a410b42ecb6e..601974df4114 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_ap.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
> @@ -1072,7 +1072,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
>
> int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
> {
> - struct list_head *plist, *phead;
> + struct list_head *plist, *phead, *temp;
> struct rtw_wlan_acl_node *paclnode;
> struct sta_priv *pstapriv = &padapter->stapriv;
> struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
> @@ -1083,7 +1083,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
> spin_lock_bh(&pacl_node_q->lock);
>
> phead = get_list_head(pacl_node_q);
> - list_for_each(plist, phead) {
> + list_for_each_safe(plist, temp, phead) {
> paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
>
> if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
> --
> 2.20.1
>