diff options
| author | Christian Brauner <brauner@kernel.org> | 2025-11-03 15:57:27 +0100 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2025-11-04 12:36:57 +0100 |
| commit | c8ad3098e1272444b6c75910d6196a36f5c8bc17 (patch) | |
| tree | 0da2526eaf03a44abfa7d5e20675c3870f3f6950 | |
| parent | a85787996aa97412223ff1975f5cd44b592e2f5f (diff) | |
cred: add prepare credential guard
A lot of code uses the following pattern:
* prepare new credentials
* modify them for their use-case
* drop them
Support that easier with the new guard infrastructure.
Link: https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-1-b447b82f2c9b@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
| -rw-r--r-- | include/linux/cred.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h index 6ea2d81a740b..343a140a6ba2 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -280,6 +280,11 @@ static inline void put_cred(const struct cred *cred) put_cred_many(cred, 1); } +DEFINE_CLASS(prepare_creds, + struct cred *, + if (_T) put_cred(_T), + prepare_creds(), void) + DEFINE_FREE(put_cred, struct cred *, if (!IS_ERR_OR_NULL(_T)) put_cred(_T)) /** |
