diff options
author | Cristian Stoica <cristian.stoica@freescale.com> | 2015-01-27 04:54:27 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-02-04 04:59:41 -0500 |
commit | c47689931fff5f8882a923bbd8d8590f038fa097 (patch) | |
tree | 8efcceeb5d237047a443cf8f69ac64956cc6ade9 /crypto/tcrypt.c | |
parent | db71f29a1c327f3824c1c0919937965b36d67b80 (diff) |
crypto: tcrypt - fix buflen reminder calculation
- This fixes the intent of the code to limit the last scatterlist to
either a full PAGE or a fraction of it, depending on the number of
pages needed by buflen and the available space advertised by XBUFLEN.
The original code always sets the last scatterlist to a fraction of a
PAGE because the first 'if' is never executed.
- Rearrange the second part of the code to remove the conditional from
the loop
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r-- | crypto/tcrypt.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 004349576ba1..2b2486ad26ef 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -250,19 +250,19 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE], | |||
250 | int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE; | 250 | int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE; |
251 | int k, rem; | 251 | int k, rem; |
252 | 252 | ||
253 | np = (np > XBUFSIZE) ? XBUFSIZE : np; | ||
254 | rem = buflen % PAGE_SIZE; | ||
255 | if (np > XBUFSIZE) { | 253 | if (np > XBUFSIZE) { |
256 | rem = PAGE_SIZE; | 254 | rem = PAGE_SIZE; |
257 | np = XBUFSIZE; | 255 | np = XBUFSIZE; |
256 | } else { | ||
257 | rem = buflen % PAGE_SIZE; | ||
258 | } | 258 | } |
259 | |||
259 | sg_init_table(sg, np); | 260 | sg_init_table(sg, np); |
260 | for (k = 0; k < np; ++k) { | 261 | np--; |
261 | if (k == (np-1)) | 262 | for (k = 0; k < np; k++) |
262 | sg_set_buf(&sg[k], xbuf[k], rem); | 263 | sg_set_buf(&sg[k], xbuf[k], PAGE_SIZE); |
263 | else | 264 | |
264 | sg_set_buf(&sg[k], xbuf[k], PAGE_SIZE); | 265 | sg_set_buf(&sg[k], xbuf[k], rem); |
265 | } | ||
266 | } | 266 | } |
267 | 267 | ||
268 | static void test_aead_speed(const char *algo, int enc, unsigned int secs, | 268 | static void test_aead_speed(const char *algo, int enc, unsigned int secs, |