From patchwork Sat Jan 4 06:39:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leesoo Ahn X-Patchwork-Id: 13926110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9C05E77188 for ; Sat, 4 Jan 2025 06:40:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4322A6B0082; Sat, 4 Jan 2025 01:40:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E2176B0088; Sat, 4 Jan 2025 01:40:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AA0E6B0089; Sat, 4 Jan 2025 01:40:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0CD1E6B0082 for ; Sat, 4 Jan 2025 01:40:12 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6F1C416040B for ; Sat, 4 Jan 2025 06:40:11 +0000 (UTC) X-FDA: 82968819822.19.D8DAAAB Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf22.hostedemail.com (Postfix) with ESMTP id 9ECC1C0005 for ; Sat, 4 Jan 2025 06:40:09 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf22.hostedemail.com: domain of yisooan.dev@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=yisooan.dev@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735972809; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=d/r6eAJCWKnJpEM6xoY5X6KkYyUPd9NQ1z6Kz8gkzw8=; b=Vc1PiyFWugUl87AcCPvjlDKEVn8zNchC0RzjBjzkh/1pQkHnuzFtyoUsoRmz3PeakEVPV6 YUMnjlU4tRK6iueNc1RKDKH51hdbokKZWXNbJ5/sAE5tMXMU0wdgg37/6EFFPh7uQG+0VM 6T/LUF1Ttv6p9zCbF2vjA6l8b23ZHTQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf22.hostedemail.com: domain of yisooan.dev@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=yisooan.dev@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735972809; a=rsa-sha256; cv=none; b=GlUfH8CVQO5kGYiOoOaJ8PeB2AUKN76QQTaCd0dFdf5yFOxobmlkfBwpUI+amBs6UgW/ah kYcsnm2yGpP4mRzdC1t/nsTLM72UdJd0RYqNcB1qQTf07eVcmkxtoJpsolqztbENFU/Rb7 4W6XgNOe5mGtLddulIRjmyMjbxhgRyE= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2166360285dso181898145ad.1 for ; Fri, 03 Jan 2025 22:40:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735972808; x=1736577608; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d/r6eAJCWKnJpEM6xoY5X6KkYyUPd9NQ1z6Kz8gkzw8=; b=blXGweLUd/LaCdq6Ww24VbTfjvlu8h1U0t/+eR9Ly2GVeNcFr7aVF3xYaoUMfh2F1x ImMxDc04qilQSCcmc+rocJSBYXQsUkL4WHoOn+Mxn7zHN0Taa3481jXnf12O7FaoFzgW Cmq561vcDEbvNI2kUzXfOKAS0TTJ+Lzl0TLVCWucrS+sZoDdOwpnTzNRoL+j4EzkMtjL VXb7VBBeXbsLcXeCpEabMxiyU4jPk1NpPAchImqpgnMgKM/xvuxukfcgNVDD6EjA+FIo e7E0loFgYQW4bbzTQO2tosd4kn4V4ZOipJJjqGQkcz0kyReHnomJ9sW9+xk72L/mTdbo Pn3Q== X-Forwarded-Encrypted: i=1; AJvYcCULI2Xs202spvQP02Hye47Kb73Fpkj4CYmhySUVF+kZwtZ31mwZfWjIqlYGIiAmbiuxXQqo9E4T0A==@kvack.org X-Gm-Message-State: AOJu0YxNyLzbVVikDBa1uD0WponK57bxmHjqy4ZsMj/nwS7GESfV1lrS 1qPiIGJSXEbTcp1JTSLkdNyd45wESpcPbDIeZ+MTinFEw+67uV39Nbz+nw== X-Gm-Gg: ASbGncu+sH3EdNI4e26heRbo5RuKRWWegKLhVIN+y5jujgS2AoQvbv9S9CKoCMPUwcE bMESFfGeTJFXGgoub5cjNnY15DAsVISTTr32PpNl/FAodizAz3gzUPHQFzFg80IueG2ubgFod0T YyP7w38V4HIssm5W4vvrTJOBMYyMHazO6/tO7hArrTdQkgZYTivBXZCSdeMwk/i4K1eEcacKqOg xU/u1ZQI5eInqNKVqutv30nccxwYAJoaSA0RHjxZX9m11cQs2vsBtH/HGRpRFQe X-Google-Smtp-Source: AGHT+IHCLtI8SUAFxLHxoKUtgA9nRM7ZNzuS2BmhmbipdvEHHgYPZQN8/LmncPqaI2Py7FqFz6TeNg== X-Received: by 2002:a17:903:2286:b0:215:cbbf:8926 with SMTP id d9443c01a7336-219e6f10978mr716666215ad.35.1735972808312; Fri, 03 Jan 2025 22:40:08 -0800 (PST) Received: from localhost.localdomain ([1.213.237.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc96eae7sm254771415ad.85.2025.01.03.22.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 22:40:08 -0800 (PST) From: Leesoo Ahn To: lsahn@ooseel.net Cc: Andrew Morton , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: ensure the uniformity of arguments passed to do_mmap(..) Date: Sat, 4 Jan 2025 15:39:25 +0900 Message-ID: <20250104063925.1544944-1-lsahn@ooseel.net> X-Mailer: git-send-email 2.46.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 9ECC1C0005 X-Rspamd-Server: rspam12 X-Stat-Signature: ooeojwbyr8mx3t33dha1a8ee1m7nehgw X-Rspam-User: X-HE-Tag: 1735972809-145166 X-HE-Meta: U2FsdGVkX1/ftrg69ArR/7ilDDe8BJEeWp3Sl3YVcFdnOkba2y8MxvOxvi7vhraD1q0XpE3ZqvfjVUEdOOi6O8YFQqJ+beFF/6qhYA6i5pPZMhYMC7uMnZ3LZhmUxGylVCWMxzn1n0/NG2dy7oFWhZO0w3DEl8ljDMWEgd5RTNVXBJOlu9JlSW5VasoyQ9pp9TOQdlUWXlEd+0X7fWvO2/G2Cy+4+8h/z+14fWKXZTZXy1e2uTyruwPV8ObK/Mtirg93nJOgQgqWS3xiZeql7ZsfFhuq80DmkgPXT++M16+4LCKYjwqwAr1KkYuwsvIENpi2hJJ8gZbJDMmu+2CJdq5EofLvDFgcew8oLMJsq39VeFPzodtMUOjySEN39XeESc8+nocaYpVer//STs57bacxxIXCl1Hu7ShEhBGwoyGEgVCxtQBxB/Nz75YrS6ampkEd420wQtvOybZZbqFz7Fua7XT95TuRja4S3swkosKP2IBf1MAHFudy2++i6Ub9uNwHDVajCqTTESmR0O0pLpk/4zpnr59CaR6jACE2/uyzanA/5qEeUtx7BBcv3Pg+UmLY01SIX+HnwVS5VW6XCX8BipI9Nz7zOowbPS4M/RGpgA3UWrBaCFyOmsHdAFNCzBmJS68jLPFu398KBN5uwqQJdbhot98rTu0X3sUlIu6W42gZDXp+4XXtktP0+9xNLxrjZss25qNQsjizETrwsCESAQuZh5M0c5fI+q4j7Yl4lcWPgZ1ZYsVkocDzUxZ0QGnVHNbd5fEE1kpQVu+p58dfwc2OEL7J9Krr/GRt2R9YDhJMHRHKtB4/lBJkzEaDJEj70LiMkc3LR4ssSmOI5rSKMC1SWYPDVEIH5v5ZTfqdB5TRt9etdAEjaMWwDbgNEJ2seIjW/EPwuai2HS/GucyGrMwiDBLmYdUfA/8hmlKnvufDqSl23NOAvovHUrOdS+tR1LDD/xUUFPn7Y7s 62ulEQ5+ QZbfjr93YwpMJY6BdWUbCnQavSh/inXLZfiDDBMMWrmYoqJ0nfqYgSeiOlBk4yHN0RJptm/kvu1gshIdRUUP0sL78L1y813J9oofD389koobuH9MdtapRGiZJM4Y3dEGpJXLA+7mcTFq2YSmwrxJzMmjDnL4ilhbPPidjQYk3Ia9vGuXB24a6mNyPYvuMAxdEhS1jnQzgjzCYyGF+9c2u1bQsJnqFldDm7Zsz77OP3zz0dNZBbHwTRy5racsG5bFdixYuJdNyDiL5+0srs9l6lMmnGvvq9H53cVazUIfRMVV6cWxgDH/lIhqehzcHaPPCSAUgrK9m9MGzTjpjiih/b2M/2pc4UjJTO2KaKIxApVroaJaCl/pFnF2sdRheaCfT8EfnfTDukuofrBJyyC2O78QQ7mPRuhQAAyxf X-Bogosity: Ham, tests=bogofilter, spamicity=0.000023, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Standardize the way of passing a value to @populate parameter of do_mmap(..) as follow: 1. Caller must initialize the variable to 0, except it's clarified as the name of the variable, 'unused'. 2. do_mmap(..) doesn't take care of its initialization. This patch has a couple of changes that: - callers initialize the variable to 0. - remove the line of initialization inside do_mmap(..) Signed-off-by: Leesoo Ahn --- mm/mmap.c | 2 -- mm/nommu.c | 2 -- mm/util.c | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index d32b7e701058..4aebb1440c35 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -289,8 +289,6 @@ unsigned long do_mmap(struct file *file, unsigned long addr, struct mm_struct *mm = current->mm; int pkey = 0; - *populate = 0; - if (!len) return -EINVAL; diff --git a/mm/nommu.c b/mm/nommu.c index 9cb6e99215e2..fa69cd8271af 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -1016,8 +1016,6 @@ unsigned long do_mmap(struct file *file, int ret; VMA_ITERATOR(vmi, current->mm, 0); - *populate = 0; - /* decide whether we should attempt the mapping, and if so what sort of * mapping */ ret = validate_mmap_request(file, addr, len, prot, flags, pgoff, diff --git a/mm/util.c b/mm/util.c index c1c3b06ab4f9..728effcab217 100644 --- a/mm/util.c +++ b/mm/util.c @@ -570,7 +570,7 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, { unsigned long ret; struct mm_struct *mm = current->mm; - unsigned long populate; + unsigned long populate = 0; LIST_HEAD(uf); ret = security_mmap_file(file, prot, flag);