]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sev-dev: use guard for path
authorChristian Brauner <brauner@kernel.org>
Mon, 3 Nov 2025 14:57:28 +0000 (15:57 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 4 Nov 2025 11:37:00 +0000 (12:37 +0100)
Just use a guard and also move the path_put() out of the credential
change's scope. There's no need to do this with the overridden
credentials.

Link: https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-2-b447b82f2c9b@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/crypto/ccp/sev-dev.c

index 0d13d47c164bb766a3093353cfe607f74177d103..c5e22af04abb0e311661537a9d3e728780511137 100644 (file)
@@ -259,8 +259,8 @@ static int sev_cmd_buffer_len(int cmd)
 
 static struct file *open_file_as_root(const char *filename, int flags, umode_t mode)
 {
+       struct path root __free(path_put) = {};
        struct file *fp;
-       struct path root;
        struct cred *cred;
        const struct cred *old_cred;
 
@@ -275,7 +275,6 @@ static struct file *open_file_as_root(const char *filename, int flags, umode_t m
        old_cred = override_creds(cred);
 
        fp = file_open_root(&root, filename, flags, mode);
-       path_put(&root);
 
        put_cred(revert_creds(old_cred));