lkml.org 
[lkml]   [2011]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] mpi/mpi-mpow: NULL dereference on allocation failure
We can't call mpi_free() on the elements if the first kzalloc() fails.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/lib/mpi/mpi-mpow.c b/lib/mpi/mpi-mpow.c
index 4cc7593..7328d0d 100644
--- a/lib/mpi/mpi-mpow.c
+++ b/lib/mpi/mpi-mpow.c
@@ -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;
}

\
 
 \ /
  Last update: 2011-11-21 15:53    [W:0.031 / U:0.804 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site