ANDROID: fuse: Open-code vma_set_file() logic in fuse_backing_mmap()

Manual manipulation of vma->vm_file and file reference counts in
fuse_backing_mmap() is error-prone.

Open-code the logic of vma_set_file() using swap() to safely
transfer the file reference and ensure proper reference counting
during VMA setup, as vma_set_file() is not available in this
kernel version.

Bug: 498749316
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Cherrypick-From: https://android-review.googlesource.com/q/commit:5c3d7b8761264e2a2deb121020bb933273b240ba
Merged-In: I22ba0618f9fde6b698aeeeff2005830c4392969c
Change-Id: I22ba0618f9fde6b698aeeeff2005830c4392969c
[dhavale: as mentioned in updated commit message, this patch is adjusted
to account for lack of vma_set_file() helper ]
This commit is contained in:
Sandeep Dhavale 2026-04-14 15:07:58 -07:00 • committed by Alexander Martinz
commit 4884b8ae4c
No known key found for this signature in database
GPG key ID: CF15BDD9A321A9B2

View file

@ -1064,14 +1064,12 @@ ssize_t fuse_backing_mmap(struct file *file, struct vm_area_struct *vma)
if (WARN_ON(file != vma->vm_file))
return -EIO;
vma->vm_file = get_file(backing_file);
get_file(backing_file);
swap(vma->vm_file, backing_file);
fput(backing_file);
ret = call_mmap(vma->vm_file, vma);
if (ret)
fput(backing_file);
else
fput(file);
return ret;
if (file->f_flags & O_NOATIME)
return ret;