This clearly indicates the double-credential override and makes the code a lot easier to grasp with one glance. Signed-off-by: Christian Brauner --- fs/overlayfs/dir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 3eb0bb0b8f3b..dad818de4386 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -1387,7 +1387,6 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir, static int ovl_create_tmpfile(struct file *file, struct dentry *dentry, struct inode *inode, umode_t mode) { - const struct cred *new_cred __free(put_cred) = NULL; struct path realparentpath; struct file *realfile; struct ovl_file *of; @@ -1396,10 +1395,10 @@ static int ovl_create_tmpfile(struct file *file, struct dentry *dentry, int flags = file->f_flags | OVL_OPEN_FLAGS; int err; - scoped_class(override_creds_ovl, old_cred, dentry->d_sb) { - new_cred = ovl_setup_cred_for_create(dentry, inode, mode, old_cred); - if (IS_ERR(new_cred)) - return PTR_ERR(new_cred); + with_ovl_creds(dentry->d_sb) { + scoped_class(ovl_override_creator_creds, cred, dentry, inode, mode) { + if (IS_ERR(cred)) + return PTR_ERR(cred); ovl_path_upper(dentry->d_parent, &realparentpath); realfile = backing_tmpfile_open(&file->f_path, flags, &realparentpath, @@ -1425,6 +1424,7 @@ static int ovl_create_tmpfile(struct file *file, struct dentry *dentry, ovl_file_free(of); } } + } return err; } -- 2.47.3