diff options
author | Ingo Molnar <mingo@kernel.org> | 2019-07-08 12:04:41 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2019-07-08 12:04:41 -0400 |
commit | 552a031ba12a4236be107a5b082a399237758a5d (patch) | |
tree | a2bcdeb651b360013dbb654bbcd61dbaf51e0331 /lib/mpi/mpi-pow.c | |
parent | f584dd32edc5d4400d7ceb92111a89f0c1f6651f (diff) | |
parent | 0ecfebd2b52404ae0c54a878c872bb93363ada36 (diff) |
Merge tag 'v5.2' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'lib/mpi/mpi-pow.c')
-rw-r--r-- | lib/mpi/mpi-pow.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c index 82b19e4f1189..2fd7a46d55ec 100644 --- a/lib/mpi/mpi-pow.c +++ b/lib/mpi/mpi-pow.c | |||
@@ -24,6 +24,7 @@ | |||
24 | int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) | 24 | int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) |
25 | { | 25 | { |
26 | mpi_ptr_t mp_marker = NULL, bp_marker = NULL, ep_marker = NULL; | 26 | mpi_ptr_t mp_marker = NULL, bp_marker = NULL, ep_marker = NULL; |
27 | struct karatsuba_ctx karactx = {}; | ||
27 | mpi_ptr_t xp_marker = NULL; | 28 | mpi_ptr_t xp_marker = NULL; |
28 | mpi_ptr_t tspace = NULL; | 29 | mpi_ptr_t tspace = NULL; |
29 | mpi_ptr_t rp, ep, mp, bp; | 30 | mpi_ptr_t rp, ep, mp, bp; |
@@ -150,13 +151,11 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) | |||
150 | int c; | 151 | int c; |
151 | mpi_limb_t e; | 152 | mpi_limb_t e; |
152 | mpi_limb_t carry_limb; | 153 | mpi_limb_t carry_limb; |
153 | struct karatsuba_ctx karactx; | ||
154 | 154 | ||
155 | xp = xp_marker = mpi_alloc_limb_space(2 * (msize + 1)); | 155 | xp = xp_marker = mpi_alloc_limb_space(2 * (msize + 1)); |
156 | if (!xp) | 156 | if (!xp) |
157 | goto enomem; | 157 | goto enomem; |
158 | 158 | ||
159 | memset(&karactx, 0, sizeof karactx); | ||
160 | negative_result = (ep[0] & 1) && base->sign; | 159 | negative_result = (ep[0] & 1) && base->sign; |
161 | 160 | ||
162 | i = esize - 1; | 161 | i = esize - 1; |
@@ -281,8 +280,6 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) | |||
281 | if (mod_shift_cnt) | 280 | if (mod_shift_cnt) |
282 | mpihelp_rshift(rp, rp, rsize, mod_shift_cnt); | 281 | mpihelp_rshift(rp, rp, rsize, mod_shift_cnt); |
283 | MPN_NORMALIZE(rp, rsize); | 282 | MPN_NORMALIZE(rp, rsize); |
284 | |||
285 | mpihelp_release_karatsuba_ctx(&karactx); | ||
286 | } | 283 | } |
287 | 284 | ||
288 | if (negative_result && rsize) { | 285 | if (negative_result && rsize) { |
@@ -299,6 +296,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) | |||
299 | leave: | 296 | leave: |
300 | rc = 0; | 297 | rc = 0; |
301 | enomem: | 298 | enomem: |
299 | mpihelp_release_karatsuba_ctx(&karactx); | ||
302 | if (assign_rp) | 300 | if (assign_rp) |
303 | mpi_assign_limb_space(res, rp, size); | 301 | mpi_assign_limb_space(res, rp, size); |
304 | if (mp_marker) | 302 | if (mp_marker) |