From patchwork Thu Sep 5 02:17:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhong jiang X-Patchwork-Id: 11132017 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E93914F7 for ; Thu, 5 Sep 2019 02:21:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 543212087E for ; Thu, 5 Sep 2019 02:21:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 543212087E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5F1D86B0003; Wed, 4 Sep 2019 22:21:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 57A9F6B0005; Wed, 4 Sep 2019 22:21:17 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4745E6B0006; Wed, 4 Sep 2019 22:21:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 1E9706B0003 for ; Wed, 4 Sep 2019 22:21:17 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id B504A180AD802 for ; Thu, 5 Sep 2019 02:21:16 +0000 (UTC) X-FDA: 75899264952.28.key98_b097d915d710 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,zhongjiang@huawei.com,:akpm@linux-foundation.org:vbabka@suse.cz:mhocko@kernel.org:zhongjiang@huawei.com::linux-kernel@vger.kernel.org,RULES_HIT:30036:30054:30070,0,RBL:45.249.212.32:@huawei.com:.lbl8.mailshell.net-62.18.2.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: key98_b097d915d710 X-Filterd-Recvd-Size: 2528 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Sep 2019 02:21:15 +0000 (UTC) Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 1C4D95E9A6A9F53753EB; Thu, 5 Sep 2019 10:21:12 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Thu, 5 Sep 2019 10:21:03 +0800 From: zhong jiang To: , CC: , , , Subject: [PATCH v2] mm: Unsigned 'nr_pages' always larger than zero Date: Thu, 5 Sep 2019 10:17:51 +0800 Message-ID: <1567649871-60594-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With the help of unsigned_lesser_than_zero.cocci. Unsigned 'nr_pages' compare with zero. And __gup_longterm_locked pass an long local variant 'rc' to check_and_migrate_cma_pages. Hence it is nicer to change the parameter to long to fix the issue. Fixes: 932f4a630a69 ("mm/gup: replace get_user_pages_longterm() with FOLL_LONGTERM") Signed-off-by: zhong jiang --- mm/gup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 23a9f9c..ee0b71f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1433,13 +1433,13 @@ static struct page *new_non_cma_page(struct page *page, unsigned long private) static long check_and_migrate_cma_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, - unsigned long nr_pages, + long nr_pages, struct page **pages, struct vm_area_struct **vmas, unsigned int gup_flags) { - unsigned long i; - unsigned long step; + long i; + long step; bool drain_allow = true; bool migrate_allow = true; LIST_HEAD(cma_page_list); @@ -1520,7 +1520,7 @@ static long check_and_migrate_cma_pages(struct task_struct *tsk, static long check_and_migrate_cma_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, - unsigned long nr_pages, + long nr_pages, struct page **pages, struct vm_area_struct **vmas, unsigned int gup_flags)