Merge remote-tracking branch 'origin/pr/2399' into mbedtls-2.7

* origin/pr/2399:
  Add ChangeLog entry
  fix memory leak in mpi_miller_rabin()
diff --git a/ChangeLog b/ChangeLog
index 6964b05..55f416e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,8 @@
    * Update test certificates that were about to expire. Reported by
      Bernhard M. Wiedemann in #2357.
    * Make NV seed test support MBEDTLS_ENTROPY_FORCE_SHA256.
+   * Fix memory leak in in mpi_miller_rabin(). Contributed by
+     Jens Wiklander <jens.wiklander@linaro.org> in #2363.
 
 Changes
    * Make `make clean` clean all programs always. Fixes #1862.
diff --git a/library/bignum.c b/library/bignum.c
index d142fe6..2b0a145 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -2138,7 +2138,8 @@
             }
 
             if (count++ > 30) {
-                return MBEDTLS_ERR_MPI_NOT_ACCEPTABLE;
+                ret = MBEDTLS_ERR_MPI_NOT_ACCEPTABLE;
+                goto cleanup;
             }
 
         } while ( mbedtls_mpi_cmp_mpi( &A, &W ) >= 0 ||