Browse Source

MPILIB: Add a missing ENOMEM check

Add a missing ENOMEM check.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
David Howells 13 years ago
parent
commit
4bf1924c00
1 changed files with 2 additions and 0 deletions
  1. 2 0
      lib/mpi/mpicoder.c

+ 2 - 0
lib/mpi/mpicoder.c

@@ -255,6 +255,8 @@ void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign)
 	if (!n)
 	if (!n)
 		n++;		/* avoid zero length allocation */
 		n++;		/* avoid zero length allocation */
 	p = buffer = kmalloc(n, GFP_KERNEL);
 	p = buffer = kmalloc(n, GFP_KERNEL);
+	if (!p)
+		return NULL;
 
 
 	for (i = a->nlimbs - 1; i >= 0; i--) {
 	for (i = a->nlimbs - 1; i >= 0; i--) {
 		alimb = a->d[i];
 		alimb = a->d[i];