From: Kalle Valo <kvalo@codeaurora.org>
To: Tony Chuang <yhchuang@realtek.com>
Cc: "linux-wireless\@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH 5/6] rtw88: mac: remove dangerous while (1)
Date: Fri, 03 May 2019 14:26:55 +0300 [thread overview]
Message-ID: <87muk3kccg.fsf@kamboji.qca.qualcomm.com> (raw)
In-Reply-To: <F7CD281DE3E379468C6D07993EA72F84D17E871A@RTITMBSVM04.realtek.com.tw> (Tony Chuang's message of "Fri, 3 May 2019 11:22:56 +0000")
Tony Chuang <yhchuang@realtek.com> writes:
>> Subject: Re: [PATCH 5/6] rtw88: mac: remove dangerous while (1)
>>
>> <yhchuang@realtek.com> writes:
>>
>> > From: Yan-Hsuan Chuang <yhchuang@realtek.com>
>> >
>> > Not to use while (1) to parse power sequence commands in an array.
>> > Put the statement (when cmd is not NULL) instead to make the loop stop
>> > when the next fetched command is NULL.
>> >
>> > Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
>> > ---
>> > drivers/net/wireless/realtek/rtw88/mac.c | 9 +++------
>> > 1 file changed, 3 insertions(+), 6 deletions(-)
>> >
>> > diff --git a/drivers/net/wireless/realtek/rtw88/mac.c
>> b/drivers/net/wireless/realtek/rtw88/mac.c
>> > index 25a923b..7487b2e 100644
>> > --- a/drivers/net/wireless/realtek/rtw88/mac.c
>> > +++ b/drivers/net/wireless/realtek/rtw88/mac.c
>> > @@ -203,17 +203,14 @@ static int rtw_pwr_seq_parser(struct rtw_dev
>> *rtwdev,
>> > return -EINVAL;
>> > }
>> >
>> > - do {
>> > - cmd = cmd_seq[idx];
>> > - if (!cmd)
>> > - break;
>> > -
>> > + while ((cmd = cmd_seq[idx])) {
>> > ret = rtw_sub_pwr_seq_parser(rtwdev, intf_mask, cut_mask, cmd);
>> > if (ret)
>> > return -EBUSY;
>> >
>> > + /* fetch next command */
>> > idx++;
>> > - } while (1);
>> > + };
>>
>> I dount see how this is any better, with a suitable bug you can still
>> have a neverending loop, right? I was thinking more something like this:
>>
>> count = 100;
>> do {
>> ....
>> } while (count--);
>>
>> That way the won't be more than 100 loops no matter how many bugs there
>> are :) Of course I have no idea what would be a good value for count.
>>
>
> To make this totally safe, I think we need to re-write the power seq parsing code.
> I think I should drop this patch, and write a better code later.
>
> And also re-write the polling command, to remove the while (1).
Sounds good to me.
--
Kalle Valo
next prev parent reply other threads:[~2019-05-03 11:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-03 10:31 [PATCH 0/6] rtw88: minor fixes from suggestions during review yhchuang
2019-05-03 10:31 ` [PATCH 1/6] rtw88: add license for Makefile yhchuang
2019-05-03 11:03 ` Kalle Valo
2019-05-03 11:05 ` Tony Chuang
2019-05-03 10:31 ` [PATCH 2/6] rtw88: pci: use ieee80211_ac_numbers instead of 0-3 yhchuang
2019-05-03 10:31 ` [PATCH 3/6] rtw88: pci: check if queue mapping exceeds size of ac_to_hwq yhchuang
2019-05-03 10:31 ` [PATCH 4/6] rtw88: fix unassigned rssi_level in rtw_sta_info yhchuang
2019-05-03 10:31 ` [PATCH 5/6] rtw88: mac: remove dangerous while (1) yhchuang
2019-05-03 10:48 ` Johannes Berg
2019-05-03 10:52 ` Tony Chuang
2019-05-03 11:07 ` Kalle Valo
2019-05-03 11:22 ` Tony Chuang
2019-05-03 11:26 ` Kalle Valo [this message]
2019-05-03 10:31 ` [PATCH 6/6] rtw88: more descriptions about LPS yhchuang
2019-05-03 11:01 ` Kalle Valo
2019-05-03 11:04 ` Tony Chuang
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=87muk3kccg.fsf@kamboji.qca.qualcomm.com \
--to=kvalo@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
--cc=yhchuang@realtek.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).