[PATCH 02/12] sev-dev: use guard for path
Christian Brauner <[email protected]>
| Newsgroups | gmane.linux.kernel.aio.general,gmane.linux.file-systems,gmane.linux.kernel,gmane.linux.file-systems.union,gmane.linux.nfs,gmane.linux.kernel.cifs,gmane.network.samba.internals,gmane.linux.kernel.cgroups,gmane.linux.network,gmane.linux.kernel.cryptoapi |
|---|---|
| Message-ID | <20251103-work-creds-guards-prepare_creds-v1-2-b447b82f2c9b@kernel.org> |
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. Signed-off-by: Christian Brauner <[email protected]> --- drivers/crypto/ccp/sev-dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 0d13d47c164b..c5e22af04abb 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -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)); -- 2.47.3 -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: <a href=mailto:"[email protected]">[email protected]</a>