public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: "Shayne Chen (陳軒丞)" <Shayne.Chen@mediatek.com>
To: "lorenzo@kernel.org" <lorenzo@kernel.org>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"nbd@nbd.name" <nbd@nbd.name>,
	"Ryder Lee" <Ryder.Lee@mediatek.com>,
	"Money Wang (王信安)" <Money.Wang@mediatek.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Evelyn Tsai (蔡珊鈺)" <Evelyn.Tsai@mediatek.com>,
	"StanleyYP Wang (王侑邦)" <StanleyYP.Wang@mediatek.com>
Subject: Re: [PATCH mt76 5/6] wifi: mt76: mt7996: fix the temporary buffer for calibration-free data
Date: Fri, 13 Mar 2026 05:55:17 +0000	[thread overview]
Message-ID: <7c815cbffec061ab7f7102d71ff14a774dfce456.camel@mediatek.com> (raw)
In-Reply-To: <abKaN35p0J67rMOa@lore-desk>

On Thu, 2026-03-12 at 11:49 +0100, Lorenzo Bianconi wrote:
> > From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
> > 
> > Move the declaration of buf[] outside the for loop.
> > 
> > Fixes: 224c7c2be578 ("wifi: mt76: mt7996: apply calibration-free
> > data from OTP")
> > Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
> > Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
> > ---
> >  drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
> > b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
> > index 2a9c59d15894..4c733f51a03e 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
> > @@ -4104,6 +4104,7 @@ mt7996_mcu_get_cal_free_data(struct
> > mt7996_dev *dev)
> >  	}
> >  
> >  	for (band = 0; band < __MT_MAX_BAND; band++) {
> > +		u8 buf[MT7996_EEPROM_BLOCK_SIZE];
> 
> why are you moving buf here? It is only used in the inner block.
> 
> >  		const struct cal_free_data *cal;
> >  		u16 prev_block_idx = -1;
> >  		u16 adie_base;
> > @@ -4126,13 +4127,13 @@ mt7996_mcu_get_cal_free_data(struct
> > mt7996_dev *dev)
> >  			u16 eep_offset = cal[i].eep_offs;
> >  			u16 block_idx = adie_offset /
> > MT7996_EEPROM_BLOCK_SIZE;
> >  			u16 offset = adie_offset %
> > MT7996_EEPROM_BLOCK_SIZE;
> > -			u8 buf[MT7996_EEPROM_BLOCK_SIZE];
> 
> I think we should always define and initialize buf array here,
> otherwise we
> could use it with uninitialized values. Something like:
> 
> 			u8 buf[MT7996_EEPROM_BLOCK_SIZE] = {};
> 
Hi Lorenzo,

The buf array is updated only if the next offset is in a different
block. For example, offsets 0x4c and 0x4d have the same block index, so
0x4d will use the same buf data read by 0x4c, instead of reading it via
MCU command again.

So we need to preserve the values in the buf array, otherwise, it will
cause undefined behavior.

Thanks,
Shayne

> Regards,
> Lorenzo
> 
> >  
> >  			if (is_mt7996(&dev->mt76) && band ==
> > MT_BAND1 &&
> >  			    dev->var.type == MT7996_VAR_TYPE_444)
> >  				eep_offset -= MT_EE_7977BN_OFFSET;
> >  
> >  			if (prev_block_idx != block_idx) {
> > +				memset(buf, 0, sizeof(buf));
> >  				ret = mt7996_mcu_get_eeprom(dev,
> > adie_offset, buf,
> >  							   
> > MT7996_EEPROM_BLOCK_SIZE,
> >  							   
> > EEPROM_MODE_EFUSE);
> > -- 
> > 2.51.0
> > 


  reply	other threads:[~2026-03-13  5:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12  9:57 [PATCH mt76 1/6] wifi: mt76: mt7996: fix RRO EMU configuration Shayne Chen
2026-03-12  9:57 ` [PATCH mt76 2/6] wifi: mt76: mt7996: support critical packet mode for MT7990 chipsets Shayne Chen
2026-03-12 10:42   ` Lorenzo Bianconi
2026-03-12  9:57 ` [PATCH mt76 3/6] wifi: mt76: mt7996: update WFSYS reset flow " Shayne Chen
2026-03-12 10:42   ` Lorenzo Bianconi
2026-03-12  9:57 ` [PATCH mt76 4/6] wifi: mt76: mt7996: adjust timeout value for boot-up calibration commands Shayne Chen
2026-03-12 10:43   ` Lorenzo Bianconi
2026-03-12  9:57 ` [PATCH mt76 5/6] wifi: mt76: mt7996: fix the temporary buffer for calibration-free data Shayne Chen
2026-03-12 10:49   ` Lorenzo Bianconi
2026-03-13  5:55     ` Shayne Chen (陳軒丞) [this message]
2026-03-12  9:57 ` [PATCH mt76 6/6] wifi: mt76: mt7996: fix issues with manually triggered radar detection Shayne Chen
2026-03-12 10:56   ` Lorenzo Bianconi
2026-03-13  6:00     ` Shayne Chen
2026-03-12 10:39 ` [PATCH mt76 1/6] wifi: mt76: mt7996: fix RRO EMU configuration Lorenzo Bianconi

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=7c815cbffec061ab7f7102d71ff14a774dfce456.camel@mediatek.com \
    --to=shayne.chen@mediatek.com \
    --cc=Evelyn.Tsai@mediatek.com \
    --cc=Money.Wang@mediatek.com \
    --cc=Ryder.Lee@mediatek.com \
    --cc=StanleyYP.Wang@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