Skip to content

Commit 0f0e7ce

Browse files
committed
target: don't copy kernel creds
Get rid of all the boilerplate and tightly scope when the task runs with kernel creds. Link: https://patch.msgid.link/20251103-work-creds-init_cred-v1-7-cb3ec8711a6a@kernel.org Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 4601b79 commit 0f0e7ce

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

drivers/target/target_core_configfs.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3670,8 +3670,6 @@ static int __init target_core_init_configfs(void)
36703670
{
36713671
struct configfs_subsystem *subsys = &target_core_fabrics;
36723672
struct t10_alua_lu_gp *lu_gp;
3673-
struct cred *kern_cred;
3674-
const struct cred *old_cred;
36753673
int ret;
36763674

36773675
pr_debug("TARGET_CORE[0]: Loading Generic Kernel Storage"
@@ -3748,16 +3746,8 @@ static int __init target_core_init_configfs(void)
37483746
if (ret < 0)
37493747
goto out;
37503748

3751-
/* We use the kernel credentials to access the target directory */
3752-
kern_cred = prepare_kernel_cred(&init_task);
3753-
if (!kern_cred) {
3754-
ret = -ENOMEM;
3755-
goto out;
3756-
}
3757-
old_cred = override_creds(kern_cred);
3758-
target_init_dbroot();
3759-
revert_creds(old_cred);
3760-
put_cred(kern_cred);
3749+
scoped_with_kernel_creds()
3750+
target_init_dbroot();
37613751

37623752
return 0;
37633753

0 commit comments

Comments
 (0)