[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <bc5ce9ad-acbd-4f3b-91d6-10cf62bf5afc@web.de>
Date: Tue, 17 Sep 2024 11:33:14 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: kernel-janitors@...r.kernel.org, Herbert Xu <herbert@...dor.apana.org.au>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] crypto: lib/mpi - Extend support for scope-based resource
management
From: Markus Elfring <elfring@...rs.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@...rs.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
Powered by blists - more mailing lists