]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
lib/mpi: Fix karactx leak in mpi_powm
authorHerbert Xu <herbert@gondor.apana.org.au>
Mon, 24 Jun 2019 10:32:26 +0000 (18:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Jul 2019 07:52:29 +0000 (09:52 +0200)
commit3e421061981c8bb6ddfb9ebf8469146b90ba7c50
tree8f17b0335c0f814ebd733c5aa4ef147642a56bff
parent7b6532ed7a6380b5c8e3d9c3a1fefff12469c5d8
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.

Reported-by: syzbot+f7baccc38dcc1e094e77@syzkaller.appspotmail.com
Fixes: cdec9cb5167a ("crypto: GnuPG based MPI lib - source files...")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/mpi/mpi-pow.c