]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
target: don't copy kernel creds
authorChristian Brauner <brauner@kernel.org>
Sun, 2 Nov 2025 23:12:46 +0000 (00:12 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 4 Nov 2025 11:36:18 +0000 (12:36 +0100)
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>
drivers/target/target_core_configfs.c

index b19acd662726d4377036bc80a3e969748947a2e1..9e51c535ba8c61e9441aeda9cc99bff04123dc4d 100644 (file)
@@ -3670,8 +3670,6 @@ static int __init target_core_init_configfs(void)
 {
        struct configfs_subsystem *subsys = &target_core_fabrics;
        struct t10_alua_lu_gp *lu_gp;
-       struct cred *kern_cred;
-       const struct cred *old_cred;
        int ret;
 
        pr_debug("TARGET_CORE[0]: Loading Generic Kernel Storage"
@@ -3748,16 +3746,8 @@ static int __init target_core_init_configfs(void)
        if (ret < 0)
                goto out;
 
-       /* We use the kernel credentials to access the target directory */
-       kern_cred = prepare_kernel_cred(&init_task);
-       if (!kern_cred) {
-               ret = -ENOMEM;
-               goto out;
-       }
-       old_cred = override_creds(kern_cred);
-       target_init_dbroot();
-       revert_creds(old_cred);
-       put_cred(kern_cred);
+       scoped_with_kernel_creds()
+               target_init_dbroot();
 
        return 0;