diff options
author | Tudor-Dan Ambarus <tudor.ambarus@microchip.com> | 2017-05-25 10:18:07 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-11-24 08:33:41 +0100 |
commit | 4a7e0231242040513f4b78117e83aa85028ff053 (patch) | |
tree | c58c0352e0c49eb77191f62ccaadd7fb0c0c97fa /crypto | |
parent | 67b718fcf89745836ecbf15cdd46ded2b071c3b6 (diff) |
crypto: dh - fix memleak in setkey
commit ee34e2644a78e2561742bea8c4bdcf83cabf90a7 upstream.
setkey can be called multiple times during the existence
of the transformation object. In case of multiple setkey calls,
the old key was not freed and we leaked memory.
Free the old MPI key if any.
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/dh.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/dh.c b/crypto/dh.c index 9d19360e7189..df7698e4f740 100644 --- a/crypto/dh.c +++ b/crypto/dh.c @@ -84,6 +84,9 @@ static int dh_set_secret(struct crypto_kpp *tfm, void *buf, unsigned int len) struct dh_ctx *ctx = dh_get_ctx(tfm); struct dh params; + /* Free the old MPI key if any */ + dh_free_ctx(ctx); + if (crypto_dh_decode_key(buf, len, ¶ms) < 0) return -EINVAL; |