Re: [PATCH] xarray: unlock on error in xa_alloc()

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

 



On Fri, Jul 06, 2018 at 12:08:14PM -0700, Matthew Wilcox wrote:
> On Fri, Jul 06, 2018 at 09:26:46PM +0300, Dan Carpenter wrote:
> > On Fri, Jul 06, 2018 at 10:51:30AM -0700, Matthew Wilcox wrote:
> > > On Fri, Jul 06, 2018 at 08:21:01PM +0300, Dan Carpenter wrote:
> > > > We need to unlock on this error path.
> > > > 
> > > > Fixes: 29a6bfc32eb2 ("xarray: Track free entries in an XArray")
> > > > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> > > > ---
> > > > 
> > > > There "UINT_MAX + 1" is an integer overflow and is equal to zero but I
> > > > don't know what was intended there.
> > > 
> > > Ah.  I didn't realise UINT_MAX was defined as ~0U.  I had intended
> > > UINT_MAX + 1UL.  ie 0x10000000UL on 64-bit and 0 on 32-bit.
> > > 
> > 
> > I will push a Smatch check so that the wrap around on 32 bit systems
> > will generate a warning.
> 
> Do you mean "on 64-bit systems"?  Because the code as-written was correct
> on 32-bit systems and buggy on 64-bit systems.
> 
> I suppose generally, this is:
> 
> 	if (unsigned long == unsigned int + int)
> 
> where we can tell statically that the right hand side will wrap on 32-bit
> systems and not on 64-bit systems.

No no.  I'm going to print a warning any time you add two numbers
together and it wraps around.  It's normally a bug.

One idea to silence the warning would be to use #ifdef 64BIT #else.

regards,
dan carpenter



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux