Skip to content

Commit

Permalink
mpi/mpi-mpow: NULL dereference on allocation failure
Browse files Browse the repository at this point in the history
We can't call mpi_free() on the elements if the first kzalloc() fails.

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Dmitry Kasatkin <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
Dan Carpenter authored and James Morris committed Dec 7, 2011
1 parent de35353 commit fe0e94c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/mpi/mpi-mpow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -129,5 +129,6 @@ int mpi_mulpowm(MPI res, MPI *basearray, MPI *exparray, MPI m)
for (i = 0; i < (1 << k); i++)
mpi_free(G[i]);
kfree(G);
err_out:
return rc;
}

0 comments on commit fe0e94c

Please sign in to comment.