[PATCH v2 18/29] ovl: avoid pointless cred reference count bump

Christian Brauner
2024-11-25T14:11:02Z

security_inode_copy_up() allocates a set of new credentials and has
taken a reference count.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/overlayfs/copy_up.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 439bd9a5ceecc4d2f4dc5dfda7cea14c3d9411ba..3601ddfeddc2ec70764756905d528570ad1020e1 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -741,7 +741,7 @@ static int ovl_prep_cu_creds(struct dentry *dentry, struct ovl_cu_creds *cc)
return err;

if (cc->new)
- cc->old = override_creds(get_new_cred(cc->new));
+ cc->old = override_creds(cc->new);

return 0;
}
@@ -749,7 +749,7 @@ static int ovl_prep_cu_creds(struct dentry *dentry, struct ovl_cu_creds *cc)
static void ovl_revert_cu_creds(struct ovl_cu_creds *cc)
{
if (cc->new) {
- put_cred(revert_creds(cc->old));
+ revert_creds(cc->old);
put_cred(cc->new);
}
}

--
2.45.2