Skip to contentSkip to conversation

MPILIB: Add a missing ENOMEM check

PATCH In review David Howells 2 participants 3 messages Jan 18, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MPILIB: Add a missing ENOMEM check

Add a missing ENOMEM check.

---

 lib/mpi/mpicoder.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
lib/mpi/mpicoder.c +2 -0
index fe84bb9..716802b 100644
@@ -255,6 +255,8 @@ void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign)
 	if (!n)
 		n++;		/* avoid zero length allocation */
 	p = buffer = kmalloc(n, GFP_KERNEL);
+	if (!p)
+		return NULL;
 
 	for (i = a->nlimbs - 1; i >= 0; i--) {
 		alimb = a->d[i];
#1 lore raw
Quoted 4 lines · David Howells

Add a missing ENOMEM check.

Thanks.

Quoted 23 lines

---

 lib/mpi/mpicoder.c |    2 ++

 1 files changed, 2 insertions(+), 0 deletions(-)
lib/mpi/mpicoder.c +0 -0
index fe84bb9..716802b 100644
@@ -255,6 +255,8 @@ void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign)
        if (!n)

               n++;            /* avoid zero length allocation */ p = buffer = kmalloc(n, GFP_KERNEL);
+       if (!p)
+               return NULL;

       for (i = a->nlimbs - 1; i >= 0; i--) {
               alimb = a->d[i];

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html