MPILIB: Add a missing ENOMEM check
authorDavid Howells <dhowells@redhat.com>
Wed, 18 Jan 2012 10:03:54 +0000 (10:03 +0000)
committerJames Morris <jmorris@namei.org>
Thu, 19 Jan 2012 02:45:51 +0000 (13:45 +1100)
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>
lib/mpi/mpicoder.c

index fe84bb978e3b5c42befda57c206edd0b68d61684..716802b774ea9a92d58828cb1d7e99356098016b 100644 (file)
@@ -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];