Message ID | 1538687672-17795-2-git-send-email-yang.shi@linux.alibaba.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09E3517E0 for <patchwork-linux-mm@patchwork.kernel.org>; Thu, 4 Oct 2018 21:15:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF408293F7 for <patchwork-linux-mm@patchwork.kernel.org>; Thu, 4 Oct 2018 21:15:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3749295BA; Thu, 4 Oct 2018 21:15:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8B73293F7 for <patchwork-linux-mm@patchwork.kernel.org>; Thu, 4 Oct 2018 21:15:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C82E16B0269; Thu, 4 Oct 2018 17:15:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C338A6B026A; Thu, 4 Oct 2018 17:15:29 -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 B231D6B026B; Thu, 4 Oct 2018 17:15:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 6FCEF6B0269 for <linux-mm@kvack.org>; Thu, 4 Oct 2018 17:15:29 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id v88-v6so7313251pfk.19 for <linux-mm@kvack.org>; Thu, 04 Oct 2018 14:15:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=VvmIHtPAYZ1LeS/YZsTd9I9vDsz1OnTtk8G+kVjmRW4=; b=pkdJyGQ82dQ92c4+eS6LSKCLrdIpfIWRTLjGr7kNa9T01ZwGAQ+bTMc75H+LBtRHYj gbm32YsxtDMEU4JfAQCoV3SzvOJ9Enadx7RFUvPAFWtu+FIMMOZcXnO2Mrs8sQnYTIdW FZI52tpuUxUX8g307DgBZgqDX7a/OINCix74tOsePAK8i0vvULDAccEKKQxkdfrycVPZ q2e7bmOYkS9MW+OMsBAWDR9n/AniSa8O0hVBsrXBAhyAiQH6Yfkq7+2BAUFyLF/jXdKu Vkjgm6GCyJ6YsInbeod2LHj5C6eLzMRWPAwrEWWCt7vVEvixaFBAAtxWAXQ9QFJSBQY8 7m4w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: ABuFfog+6efosoA+YX5Y3Cltl8+ZUkbgWEKOLiMyHPl5zwAnqTdyZ1oJ vM8XgtQ8rMnytfx9aYKs5v2G/xl4AC2Gof69bCp0xP39nqtqA6ytplkOO9Gtr5kSq9LEETqSKas ogGWCHVxfr7Qo149sN/di2vHAPZ67QW7HG+ccmc3cthSkSPN/cd0oKFpNy4koMESd9w== X-Received: by 2002:a63:1148:: with SMTP id 8-v6mr7460840pgr.172.1538687729132; Thu, 04 Oct 2018 14:15:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV61diSo8yA3i86YswViKv/7Sj9XjM1YyqzAHSMXxs4OCmT3ZHfw+9a0thzLy2bP+26aNr0q0 X-Received: by 2002:a63:1148:: with SMTP id 8-v6mr7460793pgr.172.1538687728165; Thu, 04 Oct 2018 14:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538687728; cv=none; d=google.com; s=arc-20160816; b=icvSQxfV9T0RcEcRcVBj7iw+4EadgspjxV9pD+OeqeLLfSbkDrBXCtQ2wwivrdcX8A pu5NbM1DI1w2kV+XKXMbOQlvr45l37sqJFfbjtaOydbRjj5UMkNeGcZf+H7mCaK0xB9J Ka4W+nM8ygDoHX7XI3OtUmd5h84eO1aabGv90Tu8kGRll3wguguPwpzvDd7Os2/prxFV ALXSjESPj5XtV7CKEIuYzMBta9PhN51a4bv4vTf1JI1whnBfNw7NuiJDlPAY3MzmW4bg jGkF7S9hzcvdQ+oU3eULq2iit5wjWLGS6lMC2hqayrcQtX0hyiHDy7UQqjClntr2N2I5 SOEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=VvmIHtPAYZ1LeS/YZsTd9I9vDsz1OnTtk8G+kVjmRW4=; b=W/AIzNjiT7ThS7dCVQ+UrWHy+nKKDcuLUDfznWkHWeiCB1JCuD4pg7rhThHTzhgL2W pVaVeJ+OqYTwut+6l7c2t9+BSaNqtAEa4B78MfqzEJWKPwQbVpTLItNlO7x9p1d/EPi3 BQ2Qrm3R5TT8vIvSmaP6G7b+bVPw/uHCC6YojfbRz2tdLSPi682UB5UUqpH0nNDoBz4h SS1u87urE0kvlGPRc0GyoF7yWzE2WQxAya03RMqVlBJf3PnalIqud0v1AoOE/0nzy5do BwB099ECEP2FW2MIkuG5GFi0eleDW7kgdp48w4pRqkdFXRpnYI0XfrcDOihYpEGmkBGu rCKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out4436.biz.mail.alibaba.com (out4436.biz.mail.alibaba.com. [47.88.44.36]) by mx.google.com with ESMTPS id 20-v6si6146295pfk.287.2018.10.04.14.15.26 for <linux-mm@kvack.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 14:15:28 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) client-ip=47.88.44.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04389;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0T9zY.5M_1538687672; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T9zY.5M_1538687672) by smtp.aliyun-inc.com(127.0.0.1); Fri, 05 Oct 2018 05:14:40 +0800 From: Yang Shi <yang.shi@linux.alibaba.com> To: vbabka@suse.cz, kirill.shutemov@linux.intel.com, mhocko@kernel.org, willy@infradead.org, ldufour@linux.vnet.ibm.com, colin.king@canonical.com, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2 -mm] mm: mremap: fix unsigned compare against 0 issue Date: Fri, 5 Oct 2018 05:14:32 +0800 Message-Id: <1538687672-17795-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538687672-17795-1-git-send-email-yang.shi@linux.alibaba.com> References: <1538687672-17795-1-git-send-email-yang.shi@linux.alibaba.com> 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: <linux-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
[1/2,-mm] mm: brk: fix unsigned compare against 0 issue
|
expand
|
diff --git a/mm/mremap.c b/mm/mremap.c index 3524d16..f9d5d1f 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -566,12 +566,14 @@ static int vma_expandable(struct vm_area_struct *vma, unsigned long delta) * downgrade mmap_sem to read. */ if (old_len >= new_len) { - ret = __do_munmap(mm, addr+new_len, old_len - new_len, + int retval; + retval = __do_munmap(mm, addr+new_len, old_len - new_len, &uf_unmap, true); - if (ret < 0 && old_len != new_len) + if (retval < 0 && old_len != new_len) { + ret = retval; goto out; /* Returning 1 indicates mmap_sem is downgraded to read. */ - else if (ret == 1) + } else if (retval == 1) downgraded = true; ret = addr; goto out;
Static analysis reported unsigned compare against 0 issue according to Colin Ian King. Defined an int temp variable to check the return value of __do_munmap(). Reported-by: Colin Ian King <colin.king@canonical.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Matthew Wilcox <willy@infradead.org> Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com> --- Andrew, this should be able to be folded into the original patch. mm/mremap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)