Thread (50 messages) 50 messages, 18 authors, 2025-08-01
STALE323d LANDED

[PATCH 02/10] mm/nommu: use file_has_valid_mmap_hooks() helper

From: Lorenzo Stoakes <hidden>
Date: 2025-06-16 19:35:09
Also in: ceph-devel, intel-gfx, linux-bcachefs, linux-btrfs, linux-cifs, linux-ext4, linux-f2fs-devel, linux-fsdevel, linux-mm, linux-nfs, linux-um, linux-unionfs, linux-xfs, lkml, ntfs3, nvdimm, ocfs2-devel, v9fs
Subsystem: memory management, memory mapping, the rest · Maintainers: Andrew Morton, Liam R. Howlett, Lorenzo Stoakes, Linus Torvalds

Since commit c84bf6dd2b83 ("mm: introduce new .mmap_prepare() file
callback"), the f_op->mmap() hook has been deprecated in favour of
f_op->mmap_prepare().

Therefore, update the check for file operations supporting mmap() by using
the file_has_valid_mmap_hooks() helper function, which checks for either
f_op->mmap or f_op->mmap_prepare rather than checking only for f_op->mmap
directly.

Signed-off-by: Lorenzo Stoakes <redacted>
---
 mm/nommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index b624acec6d2e..38c22ea0a95c 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -719,7 +719,7 @@ static int validate_mmap_request(struct file *file,
 
 	if (file) {
 		/* files must support mmap */
-		if (!file->f_op->mmap)
+		if (!file_has_valid_mmap_hooks(file))
 			return -ENODEV;
 
 		/* work out if what we've got could possibly be shared
-- 
2.49.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help