public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: "Mingyen Hsieh (謝明諺)" <Mingyen.Hsieh@mediatek.com>,
	"nbd@nbd.name" <nbd@nbd.name>,
	"lorenzo@kernel.org" <lorenzo@kernel.org>
Cc: "Allan Wang (王家偉)" <Allan.Wang@mediatek.com>,
	"Eric-SY Chang (張書源)" <Eric-SY.Chang@mediatek.com>,
	"Deren Wu (武德仁)" <Deren.Wu@mediatek.com>,
	"Ryder Lee" <Ryder.Lee@mediatek.com>,
	"Quan Zhou (周全)" <Quan.Zhou@mediatek.com>,
	"Michael Lo (羅璧章)" <Michael.Lo@mediatek.com>,
	"Shayne Chen (陳軒丞)" <Shayne.Chen@mediatek.com>,
	"Sean Wang" <Sean.Wang@mediatek.com>,
	"Leon Yen (顏良儒)" <Leon.Yen@mediatek.com>,
	"KM Lin (林昆民)" <km.lin@mediatek.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH v2 2/6] wifi: mt76: mt7925: add EHT control support based on the CLC data
Date: Wed, 5 Mar 2025 01:21:14 +0000	[thread overview]
Message-ID: <d9cb9f51be984407b2f684b64400faed@realtek.com> (raw)
In-Reply-To: <b519659950744937075e823ed1a29ff345fa61e6.camel@mediatek.com>

Mingyen Hsieh (謝明諺) <Mingyen.Hsieh@mediatek.com>  wrote:
> On Tue, 2025-03-04 at 09:10 +0000, Ping-Ke Shih wrote:
> > Mingyen Hsieh <mailto:mingyen.hsieh@mediatek.com> wrote:
> > 
> > [...]
> > 
> > > 
> > > +void mt7925_regd_be_ctrl(struct mt792x_dev *dev, u8 *alpha2)
> > > +{
> > > +       struct mt792x_phy *phy = &dev->phy;
> > > +       struct mt7925_clc_rule_v2 *rule;
> > > +       struct mt7925_clc *clc;
> > > +       bool old = dev->has_eht, new = true;
> > > +       u8 *pos;
> > > +
> > > +       if (!phy->clc[MT792x_CLC_BE_CTRL])
> > > +               goto out;
> > > +
> > > +       clc = (struct mt7925_clc *)phy->clc[MT792x_CLC_BE_CTRL];
> > > +       pos = clc->data;
> > > +
> > > +       while (1) {
> > 
> > while (1) could lead infinite loop unexpectedly.
> > Adding a checking of clc->len would be safer.
> > 
> > > +               rule = (struct mt7925_clc_rule_v2 *)pos;
> > > +
> > > +               if (rule->alpha2[0] == alpha2[0] &&
> > > +                   rule->alpha2[1] == alpha2[1]) {
> > > +                       new = false;
> > > +                       break;
> > > +               }
> > > +
> > > +               /* Check the last one */
> > > +               if (rule->flag && BIT(0))
> > > +                       break;
> > > +
> 
> Hi Ping-Ke,
> 
> I designed a flag to prevent the infinite loop.

I knew. 

People believe their code is safe, but somehow `while (1)` get unexpected
result. An alternative way is to use for-loop with limit range, like

clc_end = &clc->data[clc->len];

for (pos = clc->data; pos < clc_end; pos += sizeof(*rule))

Just FYR.

> 
> > > +               pos += sizeof(*rule);
> > > +       }
> > > +
> > > +out:
> > > +       if (old == new)
> > > +               return;
> > > +
> > > +       dev->has_eht = new;
> > > +       mt7925_set_stream_he_eht_caps(phy);
> > > +}
> > > +
> > 
> > [...]
> > 
> 

  reply	other threads:[~2025-03-05  1:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04  6:28 [PATCH v2 1/6] wifi: mt76: mt7925: load the appropriate CLC data based on hardware type Mingyen Hsieh
2025-03-04  6:28 ` [PATCH v2 2/6] wifi: mt76: mt7925: add EHT control support based on the CLC data Mingyen Hsieh
2025-03-04  9:10   ` Ping-Ke Shih
2025-03-04  9:34     ` Mingyen Hsieh (謝明諺)
2025-03-05  1:21       ` Ping-Ke Shih [this message]
2025-03-05  9:32         ` Mingyen Hsieh (謝明諺)
2025-03-06  0:41           ` Ping-Ke Shih
2025-03-04  6:28 ` [PATCH v2 3/6] wifi: mt76: mt7925: update the channel usage when the regd domain changed Mingyen Hsieh
2025-03-04  9:13   ` Ping-Ke Shih
2025-03-04  6:28 ` [PATCH v2 4/6] wifi: mt76: mt7925: remove unused acpi function for clc Mingyen Hsieh
2025-03-04  6:28 ` [PATCH v2 5/6] wifi: mt76: mt792x: extend MTCL of APCI to version3 for EHT control Mingyen Hsieh
2025-03-04  6:28 ` [PATCH v2 6/6] wifi: mt76: mt7925: add MTCL support to enhance the reulatory compliance Mingyen Hsieh
2025-03-04  9:06 ` [PATCH v2 1/6] wifi: mt76: mt7925: load the appropriate CLC data based on hardware type Ping-Ke Shih
2025-03-04  9:37   ` Mingyen Hsieh (謝明諺)
2025-03-05  1:00     ` Ping-Ke Shih

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=d9cb9f51be984407b2f684b64400faed@realtek.com \
    --to=pkshih@realtek.com \
    --cc=Allan.Wang@mediatek.com \
    --cc=Deren.Wu@mediatek.com \
    --cc=Eric-SY.Chang@mediatek.com \
    --cc=Leon.Yen@mediatek.com \
    --cc=Michael.Lo@mediatek.com \
    --cc=Mingyen.Hsieh@mediatek.com \
    --cc=Quan.Zhou@mediatek.com \
    --cc=Ryder.Lee@mediatek.com \
    --cc=Sean.Wang@mediatek.com \
    --cc=Shayne.Chen@mediatek.com \
    --cc=km.lin@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    /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