Skip to content

Commit 012e332

Browse files
Christian Braunertorvalds
authored andcommitted
fs/mount_setattr: always cleanup mount_kattr
Make sure that finish_mount_kattr() is called after mount_kattr was succesfully built in both the success and failure case to prevent leaking any references we took when we built it. We returned early if path lookup failed thereby risking to leak an additional reference we took when building mount_kattr when an idmapped mount was requested. Cc: [email protected] Cc: [email protected] Fixes: 9caccd4 ("fs: introduce MOUNT_ATTR_IDMAP") Signed-off-by: Christian Brauner <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 74c78b4 commit 012e332

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/namespace.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4263,12 +4263,11 @@ SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path,
42634263
return err;
42644264

42654265
err = user_path_at(dfd, path, kattr.lookup_flags, &target);
4266-
if (err)
4267-
return err;
4268-
4269-
err = do_mount_setattr(&target, &kattr);
4266+
if (!err) {
4267+
err = do_mount_setattr(&target, &kattr);
4268+
path_put(&target);
4269+
}
42704270
finish_mount_kattr(&kattr);
4271-
path_put(&target);
42724271
return err;
42734272
}
42744273

0 commit comments

Comments
 (0)