Use the scoped ovl cred guard. Signed-off-by: Christian Brauner --- fs/overlayfs/namei.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 9c0c539b3a37..9364deac0459 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -1418,7 +1418,6 @@ bool ovl_lower_positive(struct dentry *dentry) { struct ovl_entry *poe = OVL_E(dentry->d_parent); const struct qstr *name = &dentry->d_name; - const struct cred *old_cred; unsigned int i; bool positive = false; bool done = false; @@ -1434,7 +1433,7 @@ bool ovl_lower_positive(struct dentry *dentry) if (!ovl_dentry_upper(dentry)) return true; - old_cred = ovl_override_creds(dentry->d_sb); + with_ovl_creds(dentry->d_sb) { /* Positive upper -> have to look up lower to see whether it exists */ for (i = 0; !done && !positive && i < ovl_numlower(poe); i++) { struct dentry *this; @@ -1445,8 +1444,7 @@ bool ovl_lower_positive(struct dentry *dentry) * because lookup_one_positive_unlocked() will hash name * with parentpath base, which is on another (lower fs). */ - this = lookup_one_positive_unlocked( - mnt_idmap(parentpath->layer->mnt), + this = lookup_one_positive_unlocked(mnt_idmap(parentpath->layer->mnt), &QSTR_LEN(name->name, name->len), parentpath->dentry); if (IS_ERR(this)) { @@ -1473,7 +1471,7 @@ bool ovl_lower_positive(struct dentry *dentry) dput(this); } } - ovl_revert_creds(old_cred); + } return positive; } -- 2.47.3