summaryrefslogtreecommitdiff
path: root/lib/crypto/mpi/mpiutil.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2024-08-10 14:20:57 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2024-08-17 13:55:50 +0800
commit8e3a67f2de87ee94ac11ea69beb4edc2993b17a0 (patch)
treef9d05f6e63667776697cf2642098292f7c9d91cf /lib/crypto/mpi/mpiutil.c
parentfca5cb4dd2b4a9423cb6d112cc71c33899955a1f (diff)
downloadlwn-8e3a67f2de87ee94ac11ea69beb4edc2993b17a0.tar.gz
lwn-8e3a67f2de87ee94ac11ea69beb4edc2993b17a0.zip
crypto: lib/mpi - Add error checks to extension
The remaining functions added by commit a8ea8bdd9df92a0e5db5b43900abb7a288b8a53e did not check for memory allocation errors. Add the checks and change the API to allow errors to be returned. Fixes: a8ea8bdd9df9 ("lib/mpi: Extend the MPI library") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib/crypto/mpi/mpiutil.c')
-rw-r--r--lib/crypto/mpi/mpiutil.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/crypto/mpi/mpiutil.c b/lib/crypto/mpi/mpiutil.c
index d57fd8afef64..979ece5a81d2 100644
--- a/lib/crypto/mpi/mpiutil.c
+++ b/lib/crypto/mpi/mpiutil.c
@@ -133,6 +133,8 @@ MPI mpi_copy(MPI a)
if (a) {
b = mpi_alloc(a->nlimbs);
+ if (!b)
+ return NULL;
b->nlimbs = a->nlimbs;
b->sign = a->sign;
b->flags = a->flags;