Skip to content

Commit

Permalink
crypto: scatterwalk - Fix test in scatterwalk_done
Browse files Browse the repository at this point in the history
When there is more data to be processed, the current test in
scatterwalk_done may prevent us from calling pagedone even when
we should.

In particular, if we're on an SG entry spanning multiple pages
where the last page is not a full page, we will incorrectly skip
calling pagedone on the second last page.

This patch fixes this by adding a separate test for whether we've
reached the end of a page.

Cc: [email protected]
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Jul 18, 2016
1 parent 4140139 commit 5f070e8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/scatterwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,

void scatterwalk_done(struct scatter_walk *walk, int out, int more)
{
if (!(scatterwalk_pagelen(walk) & (PAGE_SIZE - 1)) || !more)
if (!more || walk->offset >= walk->sg->offset + walk->sg->length ||
!(walk->offset & (PAGE_SIZE - 1)))
scatterwalk_pagedone(walk, out, more);
}
EXPORT_SYMBOL_GPL(scatterwalk_done);
Expand Down

0 comments on commit 5f070e8

Please sign in to comment.