Skip to content

Commit 217e78d

Browse files
committed
ovl: port ovl_fill_super() to cred guard
Use the scoped ovl cred guard. Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-41-b31603935724@kernel.org Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent fc95cda commit 217e78d

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

fs/overlayfs/super.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,6 @@ static int ovl_fill_super_creds(struct fs_context *fc, struct super_block *sb)
15401540
int ovl_fill_super(struct super_block *sb, struct fs_context *fc)
15411541
{
15421542
struct ovl_fs *ofs = sb->s_fs_info;
1543-
const struct cred *old_cred = NULL;
1544-
struct cred *cred;
15451543
int err;
15461544

15471545
err = -EIO;
@@ -1550,19 +1548,15 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc)
15501548

15511549
ovl_set_d_op(sb);
15521550

1553-
err = -ENOMEM;
1554-
if (!ofs->creator_cred)
1555-
ofs->creator_cred = cred = prepare_creds();
1556-
else
1557-
cred = (struct cred *)ofs->creator_cred;
1558-
if (!cred)
1559-
goto out_err;
1560-
1561-
old_cred = ovl_override_creds(sb);
1562-
1563-
err = ovl_fill_super_creds(fc, sb);
1551+
if (!ofs->creator_cred) {
1552+
err = -ENOMEM;
1553+
ofs->creator_cred = prepare_creds();
1554+
if (!ofs->creator_cred)
1555+
goto out_err;
1556+
}
15641557

1565-
ovl_revert_creds(old_cred);
1558+
with_ovl_creds(sb)
1559+
err = ovl_fill_super_creds(fc, sb);
15661560

15671561
out_err:
15681562
if (err) {

0 commit comments

Comments
 (0)