Commit c4768993 authored by Cristian Stoica's avatar Cristian Stoica Committed by Herbert Xu

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: default avatarCristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent db71f29a
...@@ -250,19 +250,19 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE], ...@@ -250,19 +250,19 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE; int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
int k, rem; int k, rem;
np = (np > XBUFSIZE) ? XBUFSIZE : np;
rem = buflen % PAGE_SIZE;
if (np > XBUFSIZE) { if (np > XBUFSIZE) {
rem = PAGE_SIZE; rem = PAGE_SIZE;
np = XBUFSIZE; np = XBUFSIZE;
} else {
rem = buflen % PAGE_SIZE;
} }
sg_init_table(sg, np); sg_init_table(sg, np);
for (k = 0; k < np; ++k) { np--;
if (k == (np-1)) for (k = 0; k < np; k++)
sg_set_buf(&sg[k], xbuf[k], rem);
else
sg_set_buf(&sg[k], xbuf[k], PAGE_SIZE); sg_set_buf(&sg[k], xbuf[k], PAGE_SIZE);
}
sg_set_buf(&sg[k], xbuf[k], rem);
} }
static void test_aead_speed(const char *algo, int enc, unsigned int secs, static void test_aead_speed(const char *algo, int enc, unsigned int secs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment