This loop calls list_del_init() on the list iterator so it has to use the _safe() iterator or it leads to an endless loop. Fixes: 23017c8842d2 ("staging: rtl8188eu: Use list iterators and helpers") Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index b4d81d3a856c..42cfa1e95e2c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -5378,8 +5378,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) #ifdef CONFIG_88EU_AP_MODE else { /* tx bc/mc frames after update TIM */ struct sta_info *psta_bmc; - struct list_head *xmitframe_plist, *xmitframe_phead; - struct xmit_frame *pxmitframe = NULL; + struct list_head *xmitframe_phead; + struct xmit_frame *pxmitframe, *n; struct sta_priv *pstapriv = &padapter->stapriv; /* for BC/MC Frames */ @@ -5392,11 +5392,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) spin_lock_bh(&psta_bmc->sleep_q.lock); xmitframe_phead = get_list_head(&psta_bmc->sleep_q); - list_for_each(xmitframe_plist, xmitframe_phead) { - pxmitframe = list_entry(xmitframe_plist, - struct xmit_frame, - list); - + list_for_each_entry_safe(pxmitframe, n, xmitframe_phead, + list) { list_del_init(&pxmitframe->list); psta_bmc->sleepq_len--; -- 2.30.2