mpi/mpi-mpow: NULL dereference on allocation failure
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 7 Dec 2011 11:58:26 +0000 (13:58 +0200)
committerJames Morris <jmorris@namei.org>
Wed, 7 Dec 2011 13:09:23 +0000 (00:09 +1100)
We can't call mpi_free() on the elements if the first kzalloc() fails.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: James Morris <jmorris@namei.org>
lib/mpi/mpi-mpow.c

index 4cc75933c5a7cf4e7a4d79258b2f191518cdf377..7328d0d6c748f75035a6fb42cbd85df7f3c0ffda 100644 (file)
@@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
 
        G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
        if (!G)
-               goto nomem;
+               goto err_out;
 
        /* and calculate */
        tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
@@ -129,5 +129,6 @@ nomem:
        for (i = 0; i < (1 << k); i++)
                mpi_free(G[i]);
        kfree(G);
+err_out:
        return rc;
 }