mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: lib/mpi - Extend support for scope-based resource management
@ 2024-09-17  9:33 Markus Elfring
  2024-09-17 23:27 ` kernel test robot
  2024-09-18  0:52 ` [PATCH] crypto: lib/mpi - Extend support for scope-based resource management kernel test robot
  0 siblings, 2 replies; 16+ messages in thread
From: Markus Elfring @ 2024-09-17  9:33 UTC (permalink / raw)
  To: kernel-janitors, Herbert Xu; +Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 17 Sep 2024 11:20:29 +0200

Scope-based resource management became supported for some
programming interfaces by contributions of Peter Zijlstra on 2023-05-26.
See also the commit 54da6a0924311c7cf5015533991e44fb8eb12773 ("locking:
Introduce __cleanup() based infrastructure").

Thus add a macro call so that the attribute “__free(mpi_free)” can be
applied accordingly.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 include/linux/mpi.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/mpi.h b/include/linux/mpi.h
index 47be46f36435..47db8fa5fcc8 100644
--- a/include/linux/mpi.h
+++ b/include/linux/mpi.h
@@ -19,6 +19,8 @@

 #include <linux/types.h>
 #include <linux/scatterlist.h>
+#include <linux/cleanup.h>
+#include <linux/err.h>

 #define BYTES_PER_MPI_LIMB	(BITS_PER_LONG / 8)
 #define BITS_PER_MPI_LIMB	BITS_PER_LONG
@@ -44,6 +46,8 @@ typedef struct gcry_mpi *MPI;
 /*-- mpiutil.c --*/
 MPI mpi_alloc(unsigned nlimbs);
 void mpi_free(MPI a);
+DEFINE_FREE(mpi_free, MPI, if (!IS_ERR_OR_NULL(T_)) mpi_free(T_))
+
 int mpi_resize(MPI a, unsigned nlimbs);

 MPI mpi_copy(MPI a);
--
2.46.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-10-16 11:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-17  9:33 [PATCH] crypto: lib/mpi - Extend support for scope-based resource management Markus Elfring
2024-09-17 23:27 ` kernel test robot
2024-09-18  9:26   ` [PATCH v2] " Markus Elfring
2024-10-05  5:33     ` Herbert Xu
2024-10-05  6:27       ` [PATCH v2 RESEND] " Markus Elfring
2024-10-10  8:40         ` Herbert Xu
2024-10-10  8:58           ` [v2] " Markus Elfring
2024-10-10  9:00             ` Herbert Xu
2024-10-10  9:10               ` Markus Elfring
2024-10-12 15:00           ` [PATCH v3 0/3] lib: Extending " Markus Elfring
2024-10-12 15:05             ` [PATCH v3 1/3] crypto: lib/mpi - Extend " Markus Elfring
2024-10-12 15:08             ` [PATCH v3 2/3] lib/digsig: Use scope-based resource management for two MPI variables in digsig_verify_rsa() Markus Elfring
2024-10-15 21:27               ` kernel test robot
2024-10-16 11:21               ` kernel test robot
2024-10-12 15:10             ` [PATCH v3 3/3] lib/digsig: Use scope-based resource management for two " Markus Elfring
2024-09-18  0:52 ` [PATCH] crypto: lib/mpi - Extend support for scope-based resource management kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®