linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] xarray: unlock on error in xa_alloc()
Date: Fri, 6 Jul 2018 12:08:14 -0700	[thread overview]
Message-ID: <20180706190814.GB7259@bombadil.infradead.org> (raw)
In-Reply-To: <20180706182645.orttu3jjiox3v6kn@mwanda>

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@oracle.com>
> > > ---
> > > 
> > > 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.

  reply	other threads:[~2018-07-06 19:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06 17:21 [PATCH] xarray: unlock on error in xa_alloc() Dan Carpenter
2018-07-06 17:51 ` Matthew Wilcox
2018-07-06 18:26   ` Dan Carpenter
2018-07-06 19:08     ` Matthew Wilcox [this message]
2018-07-07  5:16       ` Dan Carpenter

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=20180706190814.GB7259@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).