lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2OTUAo1OliSFCJh@kadam>
Date:   Thu, 3 Nov 2022 13:09:20 +0300
From:   Dan Carpenter <error27@...il.com>
To:     Deepak R Varma <drv@...lo.com>
Cc:     David Laight <David.Laight@...lab.com>,
        "outreachy@...ts.linux.dev" <outreachy@...ts.linux.dev>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-staging@...ts.linux.dev" <linux-staging@...ts.linux.dev>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] staging: rtl8192e: Use min_t/max_t macros for variable
 comparison

On Thu, Nov 03, 2022 at 02:48:35PM +0530, Deepak R Varma wrote:
> On Thu, Nov 03, 2022 at 11:53:45AM +0300, Dan Carpenter wrote:
> > On Thu, Nov 03, 2022 at 08:24:15AM +0000, David Laight wrote:
> > > > --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
> > > > +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
> > > > @@ -587,17 +587,12 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
> > > >  			else
> > > >  				pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
> > > >  		} else {
> > > > -			if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
> > > > -				pHTInfo->CurrentAMPDUFactor =
> > > > -						 pPeerHTCap->MaxRxAMPDUFactor;
> > > > -			else
> > > > -				pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
> > > > +			pHTInfo->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor,
> > > > +							    HT_AGG_SIZE_32K);
> > >
> > > For min() to fail there must be a signed v unsigned mismatch.
> > > Maybe that ought to be fixed.
> > >
> >
> > u32 is the right choice here.
> >
> > I'm having a hard time understanding your email.  You might be saying
> > we could declare HT_AGG_SIZE_32K as a u32 so then we could use min()
> > instead of min_t()?  HT_AGG_SIZE_32K is an enum.
> >
> > pPeerHTCap->MaxRxAMPDUFactor is a bitfield.
> >
> > 	u8 MaxRxAMPDUFactor:2;
> >
> > We will never be able to use min().
> 
> I think we could do min((u32)a, (u32)b), but it is just unwrapped min_t
> if I understand David's comment.
> 

No.  Do not do that.  I think it's a checkpatch warning.  What you have
is fine.

> >
> > > >  		}
> > > >  	}
> > > > -	if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
> > > > -		pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density;
> > > > -	else
> > > > -		pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity;
> > > > +	pHTInfo->current_mpdu_density = max_t(u8, pHTInfo->MPDU_Density,
> > > > +					      pPeerHTCap->MPDUDensity);
> > >
> > > Using u8 with max_t() really doesn't make any sense.
> >
> > Using u8 looks wrong because you would worry that one of the types is
> > larger than U8_MAX.  But it's actually fine.  The types are u8 vs another
> > bitfield.  I would probably have gone with u32 here as well.
> I will take your advise and upgrade the type to u32 as a revision.

Sounds good.  It's not something I would have asked you to redo the
patch over, but it would have been my personal preference.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ