linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ivan Safonov <insafonov@gmail.com>,
	Martin Kaiser <martin@kaiser.cx>,
	Michael Straube <straube.linux@gmail.com>,
	Simon Fong <simon.fodin@gmail.com>,
	linux-staging@lists.linux.dev, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 4/7] staging: rtl8188eu: use safe iterator in wakeup_sta_to_xmit()
Date: Wed, 9 Jun 2021 03:36:55 -0700	[thread overview]
Message-ID: <20210609103655.GD3727184@roeck-us.net> (raw)
In-Reply-To: <YL5i1ZAAAB4vSWef@mwanda>

On Mon, Jun 07, 2021 at 09:17:57PM +0300, Dan Carpenter wrote:
> These two loops call list_del_init() on the list iterator so they need to
> use the _safe() iterator to prevent a forever loop.
> 
> Fixes: 23017c8842d2 ("staging: rtl8188eu: Use list iterators and helpers")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/staging/rtl8188eu/core/rtw_xmit.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> index f57e41f817ca..d5489811c5bc 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
> @@ -1796,17 +1796,14 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
>  {
>  	u8 update_mask = 0, wmmps_ac = 0;
>  	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;
>  
>  	spin_lock_bh(&psta->sleep_q.lock);
>  
>  	xmitframe_phead = get_list_head(&psta->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);
>  
>  		switch (pxmitframe->attrib.priority) {
> @@ -1881,10 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
>  		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
> 

  reply	other threads:[~2021-06-09 10:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 18:15 [PATCH 0/7] staging: rtl8188eu: use safe version of list iterators Dan Carpenter
2021-06-07 18:17 ` [PATCH 1/7] staging: rtl8188eu: use safe iterator in stop_ap_mode() Dan Carpenter
2021-06-09 10:33   ` Guenter Roeck
2021-06-07 18:17 ` [PATCH 2/7] staging: rtl8188eu: use safe iterator in tx_beacon_hdl() Dan Carpenter
2021-06-09 10:34   ` Guenter Roeck
2021-06-07 18:17 ` [PATCH 3/7] staging: rtl8188eu: use safe iterator in dequeue_xmitframes_to_sleeping_queue() Dan Carpenter
2021-06-09 10:35   ` Guenter Roeck
2021-06-07 18:17 ` [PATCH 4/7] staging: rtl8188eu: use safe iterator in wakeup_sta_to_xmit() Dan Carpenter
2021-06-09 10:36   ` Guenter Roeck [this message]
2021-06-07 18:18 ` [PATCH 5/7] staging: rtl8188eu: use safe iterator in xmit_delivery_enabled_frames() Dan Carpenter
2021-06-09 10:37   ` Guenter Roeck
2021-06-07 18:18 ` [PATCH 6/7] staging: rtl8188eu: use safe iterator in rtl8188eu_xmitframe_complete() Dan Carpenter
2021-06-09 10:37   ` Guenter Roeck
2021-06-07 18:19 ` [PATCH 7/7] staging: rtl8188eu: delete some dead code Dan Carpenter
2021-06-09 10:39   ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210609103655.GD3727184@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=Larry.Finger@lwfinger.net \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=insafonov@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=simon.fodin@gmail.com \
    --cc=straube.linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).