Commit fe0e94c5 authored by Dan Carpenter's avatar Dan Carpenter Committed by James Morris

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent de353533
...@@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m) ...@@ -73,7 +73,7 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL); G = kzalloc((1 << k) * sizeof *G, GFP_KERNEL);
if (!G) if (!G)
goto nomem; goto err_out;
/* and calculate */ /* and calculate */
tmp = mpi_alloc(mpi_get_nlimbs(m) + 1); tmp = mpi_alloc(mpi_get_nlimbs(m) + 1);
...@@ -129,5 +129,6 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m) ...@@ -129,5 +129,6 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
for (i = 0; i < (1 << k); i++) for (i = 0; i < (1 << k); i++)
mpi_free(G[i]); mpi_free(G[i]);
kfree(G); kfree(G);
err_out:
return rc; return rc;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment