Use the scoped ovl cred guard. Reviewed-by: Amir Goldstein Signed-off-by: Christian Brauner --- fs/overlayfs/dir.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index b0e619a9b004..4fd6ddd6f4ef 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -1321,7 +1321,6 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir, struct dentry *old, struct inode *newdir, struct dentry *new, unsigned int flags) { - const struct cred *old_cred = NULL; struct ovl_renamedata ovlrd = { .old_parent = old->d_parent, .old_dentry = old, @@ -1337,11 +1336,9 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir, if (err) goto out; - old_cred = ovl_override_creds(old->d_sb); - + with_ovl_creds(old->d_sb) err = ovl_rename_upper(&ovlrd, &list); - ovl_revert_creds(old_cred); ovl_rename_end(&ovlrd); out: dput(ovlrd.new_upper); -- 2.47.3