Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -14
+8 -14
fs/overlayfs/super.c
··· 1540 1540 int ovl_fill_super(struct super_block *sb, struct fs_context *fc) 1541 1541 { 1542 1542 struct ovl_fs *ofs = sb->s_fs_info; 1543 - const struct cred *old_cred = NULL; 1544 - struct cred *cred; 1545 1543 int err; 1546 1544 1547 1545 err = -EIO; ··· 1548 1550 1549 1551 ovl_set_d_op(sb); 1550 1552 1551 - err = -ENOMEM; 1552 - if (!ofs->creator_cred) 1553 - ofs->creator_cred = cred = prepare_creds(); 1554 - else 1555 - cred = (struct cred *)ofs->creator_cred; 1556 - if (!cred) 1557 - goto out_err; 1553 + if (!ofs->creator_cred) { 1554 + err = -ENOMEM; 1555 + ofs->creator_cred = prepare_creds(); 1556 + if (!ofs->creator_cred) 1557 + goto out_err; 1558 + } 1558 1559 1559 - old_cred = ovl_override_creds(sb); 1560 - 1561 - err = ovl_fill_super_creds(fc, sb); 1562 - 1563 - ovl_revert_creds(old_cred); 1560 + with_ovl_creds(sb) 1561 + err = ovl_fill_super_creds(fc, sb); 1564 1562 1565 1563 out_err: 1566 1564 if (err) {