Search Linux Wireless

Re: [PATCH] brcmfmac: fix a loop exit condition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 23, 2021 at 01:59:36PM +0200, Johannes Berg wrote:
> On Fri, 2021-04-23 at 14:46 +0300, Dan Carpenter wrote:
> > This code is supposed to loop over the whole board_type[] string.  The
> > current code kind of works just because ascii values start 97 and the
> > string is likely shorter than that so it will break when we hit the NUL
> > terminator.  But really the condition should be "i < len" instead of
> > "i < board_type[i]".
> > 
> > Fixes: 29e354ebeeec ("brcmfmac: Transform compatible string for FW loading")
> > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> > ---
> >  drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
> > index a7554265f95f..9b75e396fc50 100644
> > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
> > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
> > @@ -34,7 +34,7 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
> >  		len = strlen(tmp) + 1;
> >  		board_type = devm_kzalloc(dev, len, GFP_KERNEL);
> >  		strscpy(board_type, tmp, len);
> > -		for (i = 0; i < board_type[i]; i++) {
> > +		for (i = 0; i < len; i++) {
> >  			if (board_type[i] == '/')
> >  				board_type[i] = '-';
> >  		}
> 
> It should probably just use strreplace() though :)

Good point.  I'll send a v2.

regards,
dan carpenter




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux