From: Christian Brauner Date: Thu, 12 Jun 2025 13:25:33 +0000 (+0200) Subject: cred: add auto cleanup method X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=377d7860c960ac8e672881bc50353d867e2f94a4;p=thirdparty%2Fkernel%2Fstable.git cred: add auto cleanup method 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 --- diff --git a/include/linux/cred.h b/include/linux/cred.h index 5658a3bfe803c..a102a10f833fb 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -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 *