Call path_get() in path_init() when dirfd doesn't belong to the current
directory and is not the root directory. Without it path_put() will be
called later without a previous path_get().

Reproducer:

mkdir /ram
mount -t ramfs none /ram
stat -C ram .
umount /ram

Without this patch umount fails with -EBUSY.

Signed-off-by: Sascha Hauer <[email protected]>
---
 fs/fs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/fs.c b/fs/fs.c
index 
d884726187dd526213f8b51a68a2e0db1bb50e58..f7859304a7b5f4158db83298b586c633668301d5
 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2251,6 +2251,7 @@ static const char *path_init(int dirfd, struct nameidata 
*nd, unsigned flags)
 
                nd->path.mnt = &f->fsdev->vfsmount;
                nd->path.dentry = f->f_path.dentry;
+               path_get(&nd->path);
                follow_mount(&nd->path);
 
                if (*s == '/')

-- 
2.47.3


Reply via email to