From 578364593bba53378e749050e374ce809203510e Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Tue, 20 Jun 2023 16:54:29 +0200 Subject: [PATCH] UBUNTU: SAUCE: overlayfs: fix reference count mismatch BugLink: https://bugs.launchpad.net/bugs/2016398 Fixes: 508fdae3f62dd ("UBUNTU: SAUCE: overlayfs: fix incorrect mnt_id of files opened from map_files") Signed-off-by: Andrea Righi --- fs/overlayfs/file.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index e3c6834d8d0f1..e9ed0b577fcd1 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -508,11 +508,14 @@ static void ovl_vm_prfile_set(struct vm_area_struct *vma, struct file *file) { get_file(file); - vma->vm_prfile = file; -#ifndef CONFIG_MMU - get_file(file); - vma->vm_region->vm_prfile = file; +#ifdef CONFIG_MMU + swap(vma->vm_prfile, file); +#else + swap(vma->vm_region->vm_prfile, file); #endif + /* Drop reference count from previous vm_file value */ + if (file) + fput(file); } static int ovl_mmap(struct file *file, struct vm_area_struct *vma) -- 2.40.1