Skip to content

Commit 89c545e

Browse files
committed
sev-dev: use prepare credential guard
Use the prepare credential guard for allocating a new set of credentials. Link: https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-3-b447b82f2c9b@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 4c5941c commit 89c545e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/crypto/ccp/sev-dev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,22 +261,22 @@ static struct file *open_file_as_root(const char *filename, int flags, umode_t m
261261
{
262262
struct path root __free(path_put) = {};
263263
struct file *fp;
264-
struct cred *cred;
265264
const struct cred *old_cred;
266265

267266
task_lock(&init_task);
268267
get_fs_root(init_task.fs, &root);
269268
task_unlock(&init_task);
270269

271-
cred = prepare_creds();
270+
CLASS(prepare_creds, cred)();
272271
if (!cred)
273272
return ERR_PTR(-ENOMEM);
273+
274274
cred->fsuid = GLOBAL_ROOT_UID;
275275
old_cred = override_creds(cred);
276276

277277
fp = file_open_root(&root, filename, flags, mode);
278278

279-
put_cred(revert_creds(old_cred));
279+
revert_creds(old_cred);
280280

281281
return fp;
282282
}

0 commit comments

Comments
 (0)