[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20190904183958.GM29434@bombadil.infradead.org>
Date:   Wed, 4 Sep 2019 11:39:58 -0700
From:   Matthew Wilcox <willy@...radead.org>
To:     "Weiny, Ira" <ira.weiny@...el.com>
Cc:     Vlastimil Babka <vbabka@...e.cz>,
        zhong jiang <zhongjiang@...wei.com>,
        "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
        "mhocko@...nel.org" <mhocko@...nel.org>,
        "anshuman.khandual@....com" <anshuman.khandual@....com>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
Subject: Re: [PATCH] mm: Unsigned 'nr_pages' always larger than zero
On Wed, Sep 04, 2019 at 06:25:19PM +0000, Weiny, Ira wrote:
> > On 9/4/19 12:26 PM, zhong jiang wrote:
> > > With the help of unsigned_lesser_than_zero.cocci. Unsigned 'nr_pages"'
> > > compare with zero. And __get_user_pages_locked will return an long
> > value.
> > > Hence, Convert the long to compare with zero is feasible.
> > 
> > It would be nicer if the parameter nr_pages was long again instead of
> > unsigned long (note there are two variants of the function, so both should be
> > changed).
> 
> Why?  What does it mean for nr_pages to be negative?  The check below seems valid.  Unsigned can be 0 so the check can fail.  IOW Checking unsigned > 0 seems ok.
> 
> What am I missing?
__get_user_pages can return a negative errno.
Powered by blists - more mailing lists