linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: ensure the uniformity of arguments passed to do_mmap(..)
@ 2025-01-04  6:39 Leesoo Ahn
  2025-01-04 16:45 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Leesoo Ahn @ 2025-01-04  6:39 UTC (permalink / raw)
  To: lsahn
  Cc: Andrew Morton, Liam R. Howlett, Lorenzo Stoakes, Vlastimil Babka,
	Jann Horn, linux-mm, linux-kernel

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 <lsahn@ooseel.net>
---
 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);
-- 
2.46.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: ensure the uniformity of arguments passed to do_mmap(..)
  2025-01-04  6:39 [PATCH] mm: ensure the uniformity of arguments passed to do_mmap(..) Leesoo Ahn
@ 2025-01-04 16:45 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2025-01-04 16:45 UTC (permalink / raw)
  To: Leesoo Ahn
  Cc: Andrew Morton, Liam R. Howlett, Lorenzo Stoakes, Vlastimil Babka,
	Jann Horn, linux-mm, linux-kernel

On Sat, Jan 04, 2025 at 03:39:25PM +0900, Leesoo Ahn wrote:
> 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.

Why?  This seems fragile.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-04 16:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-04  6:39 [PATCH] mm: ensure the uniformity of arguments passed to do_mmap(..) Leesoo Ahn
2025-01-04 16:45 ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox