summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crypto/dh.c3
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, &params) < 0)
return -EINVAL;