]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cred: add auto cleanup method
authorChristian Brauner <brauner@kernel.org>
Thu, 12 Jun 2025 13:25:33 +0000 (15:25 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 7 Jul 2025 10:24:50 +0000 (12:24 +0200)
Add a simple auto cleanup method for struct cred.

Link: https://lore.kernel.org/20250612-work-coredump-massage-v1-19-315c0c34ba94@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
include/linux/cred.h

index 5658a3bfe803c88ebaf7629b1c5eb5aa5163c91f..a102a10f833fb8301c207d39f4c5c367615251c7 100644 (file)
@@ -263,6 +263,8 @@ static inline void put_cred(const struct cred *cred)
        put_cred_many(cred, 1);
 }
 
+DEFINE_FREE(put_cred, struct cred *, if (!IS_ERR_OR_NULL(_T)) put_cred(_T))
+
 /**
  * current_cred - Access the current task's subjective credentials
  *