lib/mpi: Fix karactx leak in mpi_powm

commit c8ea9fce2baf7b643384f36f29e4194fa40d33a6 upstream.

Sometimes mpi_powm will leak karactx because a memory allocation
failure causes a bail-out that skips the freeing of karactx.  This
patch moves the freeing of karactx to the end of the function like
everything else so that it can't be skipped.

Fixes: cdec9cb5167a ("crypto: GnuPG based MPI lib - source files...")
Cc: <>
Signed-off-by: Herbert Xu <>
Reviewed-by: Eric Biggers <>
Signed-off-by: Herbert Xu <>
Signed-off-by: Greg Kroah-Hartman <>
Signed-off-by: Greg Kroah-Hartman <>
Change-Id: I0d5ad84f057c040f6271a1d61caa976295b55ae0
1 file changed