Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp414340yba; Fri, 3 May 2019 04:24:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqybQ5iUW+2fCoKlJaLQEW+QC4q0L0rBdbUytyUygb0byni7DqEhrqXT8OFR0Pa+Y9YHl41U X-Received: by 2002:a63:1852:: with SMTP id 18mr9577210pgy.283.1556882653439; Fri, 03 May 2019 04:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556882653; cv=none; d=google.com; s=arc-20160816; b=p0kdYEEz73GceEEvPARsaUfWutltI7xR1ORtuOUeGHBgE5YSqTeBZz4ll1oFwlV2QY Fbev5g8Jlqv5dz5B6F7kR+2/ixngNe9oXjt7jKtS+jakMYEDNU84ZDEG/OaKdIJTcKcc xr6tYdtgLVqwMTDbaxCb7f4reSQk0NdFAlMmiC0AmVwxt7imwzEWjUZT1AWx+762TKKC 2nCz3YoQdIXBWCSB2QY+9gzJ0hJY96tQd94rXIWekYN7xA8Lg/7PxsVyhBJ0kbLdHLA9 M6s/m41Ckdh9N7LsLZ6mFzzBG0VoE4rhkgL/1k2yr4helLriivaz0VkvT6lyP7lsqSV6 A0HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:authenticated-by; bh=cu/O6W8cyemgobwalzh0HTBguBVN+6LADYtwHzHEpJQ=; b=t25hwP6SmX8ya6zOs97yGXBh3UHHBgT68KtrifYIkIkVPHRMcp24CtlobRJaGUYEpm DmiNN4EiaV6WbPFSJ1TbuRnslyhwnNKxjBjw/Mkot9x1iX3ZYVMzmEzd9xreQYZZJK5/ lpeFFBg8cH+NcPcbDE/IIXLY3WpsdL1Q74AeGiHvKR2TaekUZz/JgwYWSYYF+Kr21Xpc Ez3I+RF+BmzN0MAfT9saDk8dca7kTl89gD35Vdh5AE3J+6rP2fNY9SldnD19TjNJRSTm YIV0KjqdTtmRZyGkSDLFa8HarmbmN4+Obw+HXZdsEDUwwVwj6qP9j/rVuqSXPkxo5WCd 6CPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si1922677pfb.85.2019.05.03.04.23.58; Fri, 03 May 2019 04:24:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbfECLXB convert rfc822-to-8bit (ORCPT + 99 others); Fri, 3 May 2019 07:23:01 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:44309 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726372AbfECLXB (ORCPT ); Fri, 3 May 2019 07:23:01 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x43BMuJf028780, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtitcasv02.realtek.com.tw[172.21.6.19]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x43BMuJf028780 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 3 May 2019 19:22:57 +0800 Received: from RTITMBSVM04.realtek.com.tw ([fe80::e404:880:2ef1:1aa1]) by RTITCASV02.realtek.com.tw ([::1]) with mapi id 14.03.0439.000; Fri, 3 May 2019 19:22:56 +0800 From: Tony Chuang To: Kalle Valo CC: "linux-wireless@vger.kernel.org" Subject: RE: [PATCH 5/6] rtw88: mac: remove dangerous while (1) Thread-Topic: [PATCH 5/6] rtw88: mac: remove dangerous while (1) Thread-Index: AQHVAaBWc+Obl4OrnkWOg3YkXAd45KZZQRVA Date: Fri, 3 May 2019 11:22:56 +0000 Message-ID: References: <1556879502-16211-1-git-send-email-yhchuang@realtek.com> <1556879502-16211-6-git-send-email-yhchuang@realtek.com> <87r29fkd9k.fsf@kamboji.qca.qualcomm.com> In-Reply-To: <87r29fkd9k.fsf@kamboji.qca.qualcomm.com> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.21.68.183] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org > Subject: Re: [PATCH 5/6] rtw88: mac: remove dangerous while (1) > > writes: > > > From: Yan-Hsuan Chuang > > > > 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 > > --- > > 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). Yan-Hsuan