From: Lorenzo Stoakes Date: Mon, 16 Jun 2025 19:33:21 +0000 (+0100) Subject: mm/nommu: use file_has_valid_mmap_hooks() helper X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6900f227f892b36f9c820e60953fe01a4c1b6fa;p=thirdparty%2Fkernel%2Fstable.git mm/nommu: use file_has_valid_mmap_hooks() helper 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 Link: https://lore.kernel.org/5f120b644b5890d1b50202d0f0d4c9f0d6b62873.1750099179.git.lorenzo.stoakes@oracle.com Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- diff --git a/mm/nommu.c b/mm/nommu.c index b624acec6d2ee..38c22ea0a95c6 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