Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp257100ybe; Wed, 4 Sep 2019 19:24:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGFrenTOXj35/BOUjUJUZwTFZefnCnekGFK75xVQKRytc3RgLEc9duh22NINtpG0gVaGtx X-Received: by 2002:a62:7646:: with SMTP id r67mr967184pfc.116.1567650292938; Wed, 04 Sep 2019 19:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567650292; cv=none; d=google.com; s=arc-20160816; b=NwdaATNEiBLMXNMkIguQqcgHHZ+ZeVOvOkuZsQsPXQizEOfMfQSREVMIt1jBkKom0l oLCjrfUcehkTDdv+kawgztcxiKKpDkWpE8yMAa3r1CVFXfJo0azfemwBtZHkmaUP9cC6 48MHuL/vNwEZpoHi6dG0xzgS8S0ZPO6iLH0GLn295EHUJoFQaNwptMLB37qJyP02OUih UYYbFVLNNHHQ66DTFjPrSUvD+mvLkrZDl2WXq5UtLRfxEB1a/W0wN2p7BUhMdbBhGefL 1tgsgoWxaSwAekRY5NPqvTFpTjARwP4wm/bu0xTq0h5LUcOubXUQkZBZnJE8RGb6EXk8 ZVDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=AW0FVkB6lLkGioWtC2QgRw9V1JaMKUo6dNRXNR5So0I=; b=ARPIcGrqMDSI/NWNipjZw8zBZKL+M7pzvD1x4xNuAeicGwG55Bwqqw4wnGTCo2NP40 VFKiTMH0Iofei1INtZfYu253AwPW4DJxjc7SS0Md7hVYVP3SgPZY8JszO0bkeGbUa4AU cj3AWYqeJw38pEtk2Y9IX3RpK0ZXZnWkrPXOcy58V1PHVBKC0gFfgo/IcAp4z1KLhMAj OCOTMMT2BIbCr+NO7CAHy4OxVwM/465amDOvAztXfoceaews3Tq6j5s89Fjo6eCFZx+V WjPcFKaz8+HjEDbGMOgatmwd25t1kq7FgaEdi/b7WKQObMsFJ1wmNy50GRAq6vnVLYN9 P8Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si423930pgi.587.2019.09.04.19.24.37; Wed, 04 Sep 2019 19:24:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730810AbfIECVN (ORCPT + 99 others); Wed, 4 Sep 2019 22:21:13 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:53152 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730447AbfIECVN (ORCPT ); Wed, 4 Sep 2019 22:21:13 -0400 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 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 1.7.12.4