From patchwork Sat Aug 1 09:08:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 11695941 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 4F276722 for ; Sat, 1 Aug 2020 09:09:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 150C82076C for ; Sat, 1 Aug 2020 09:09:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iGabIp/k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 150C82076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 120838D008B; Sat, 1 Aug 2020 05:09:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0AADF8D0081; Sat, 1 Aug 2020 05:09:08 -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 E8B508D008B; Sat, 1 Aug 2020 05:09:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id CBD118D0081 for ; Sat, 1 Aug 2020 05:09:07 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8C1EE1EF2 for ; Sat, 1 Aug 2020 09:09:07 +0000 (UTC) X-FDA: 77101425534.13.nest36_470f71226f8b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 656F018140B7B for ; Sat, 1 Aug 2020 09:09:07 +0000 (UTC) X-Spam-Summary: 1,0,0,59d1cfb1042da44d,d41d8cd98f00b204,haowenchao22@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1539:1711:1714:1730:1747:1777:1792:2393:2559:2562:2910:3138:3139:3140:3141:3142:3351:3865:3868:3871:4321:5007:6261:6653:7514:9413:9592:10004:11026:11658:11914:12114:12296:12297:12438:12517:12519:12555:12895:12986:13069:13311:13357:13894:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21740:21990:30051:30054:30070,0,RBL:209.85.215.194:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yrnfptbwogk189d3oibhqog1fnrypdq8aeennwzxpxwctss58jp79kpfr61ap.c6ahhyp6xxcxfsowt7a9fah1r4oyugk6xea5zikuo3btnsw3j3gq1emidya9k89.a-lbl8.mailshell.net-223.238.255.100,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: nest36_470f71226f8b X-Filterd-Recvd-Size: 3529 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Sat, 1 Aug 2020 09:09:06 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id z5so17257150pgb.6 for ; Sat, 01 Aug 2020 02:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UN/Dvz3hyrHMgSmeNmiv4tJktuZkgJkdeT4j8TORBL0=; b=iGabIp/kfW/rp6Hdvg5DxXklaquJZhtr7cvsmuxiOGGMYu22baXQ2d9ML+a6w3cz8z lHv4XmCp8ypBv7nd7paFUBpaVtoCLPUpyQQMt9TROdPnwJYtGbyG4PMegdeZh8nMK3Rt qBpvZ16qFzpJ6O1dQOW7fgiPvtcFKWyE/9MjM9W+fNmm/qtWsUYKTU/5jCrvejaNYKMW zUxcCZzqMm1UN4efHJvmfdr65EDt8fu5BNWzUF6Xs78QsK/NLdZHU+E5WUleaQoKUjND dQPGX3Rp2WqXNlmBo4av8RNsrhcf8e9bs6WFCXXQW3nmfjgkqWBdcNDolqwLwuVqzJX7 Kk+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UN/Dvz3hyrHMgSmeNmiv4tJktuZkgJkdeT4j8TORBL0=; b=Y9iSGb5ZQAWntr51RcanHaCY0mj9hh29NrjjyZb47QgaZex/9FD5V+UWBcdTE3iK8v 7xgnS/VspDgG4RE4MeMYPHRFw8ZjX/lKT7NnpwetJ0ziho+InZP28l9An+YCMnpX/Yeq cH4n5WCWeIk5QC6B0S19UJRloaJEFZHWlwFGtX72cED2EzT+IILDAUJJ+xMNmEqHwwzt Rv7blMMbVl84aco60kkr/uHQiWHEUm3jn8JiFXdfx+lgGjiktQKwT2DY6c9UYGFCIrg1 zwrGJ/L5oNXXcizP3poWHLZSM9mRy+9P3gerfchYOWs3xtq01QMJ0mHYKDr7/s1cllCy ptmg== X-Gm-Message-State: AOAM5327KUtxhECaDH4i34d9cbqvPfFiDbSIilsZ2drW7CBDbavO9qQq Z2nY7dAPbgwYseOPtLYOlZk= X-Google-Smtp-Source: ABdhPJx7HHXvadR3lbkPf9OdwKon3d8m8/5wxdSGns9KnUvl6/9nBW9gQsnkygYyDPQYcRviT3TPVQ== X-Received: by 2002:a63:ce15:: with SMTP id y21mr7297655pgf.163.1596272946000; Sat, 01 Aug 2020 02:09:06 -0700 (PDT) Received: from localhost.localdomain ([122.96.73.106]) by smtp.gmail.com with ESMTPSA id a193sm13491945pfa.105.2020.08.01.02.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2020 02:09:05 -0700 (PDT) From: Wenchao Hao To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wenchao Hao Subject: [PATCH] mm, mempolicy: Check parameters first in kernel_get_mempolicy Date: Sat, 1 Aug 2020 17:08:26 +0800 Message-Id: <20200801090825.5597-1-haowenchao22@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 656F018140B7B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Previous implement called untagged_addr before error check, while if the error check failed and return EINVAL, the untagged_addr is just useless work. Signed-off-by: Wenchao Hao --- mm/mempolicy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 381320671677..dac0cd0df3e1 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1632,11 +1632,11 @@ static int kernel_get_mempolicy(int __user *policy, int uninitialized_var(pval); nodemask_t nodes; - addr = untagged_addr(addr); - if (nmask != NULL && maxnode < nr_node_ids) return -EINVAL; + addr = untagged_addr(addr); + err = do_get_mempolicy(&pval, &nodes, addr, flags); if (err)