diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2005-03-22 20:10:18 -0800 |
|---|---|---|
| committer | David S. Miller <davem@sunset.davemloft.net> | 2005-03-22 20:10:18 -0800 |
| commit | ae8120eb3797dff24576ecc1aade455f336bafbb (patch) | |
| tree | 64ec93118243c9a531c9820d74d10fd75be57210 /crypto | |
| parent | 59de21037401234f88dd22a9f0a20d2641b8f5e5 (diff) | |
[CRYPTO]: Fix walk->data handling
The problem is that walk->data wasn't being incremented anymore
after my last change. This patch should fix it up.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/scatterwalk.c | 15 | ||||
| -rw-r--r-- | crypto/scatterwalk.h | 1 |
2 files changed, 12 insertions, 4 deletions
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c index 7f00bb1ff9b6..50c9461e8cc6 100644 --- a/crypto/scatterwalk.c +++ b/crypto/scatterwalk.c @@ -17,6 +17,7 @@ #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/highmem.h> +#include <asm/bug.h> #include <asm/scatterlist.h> #include "internal.h" #include "scatterwalk.h" @@ -45,6 +46,8 @@ void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg) walk->page = sg->page; walk->len_this_segment = sg->length; + BUG_ON(!sg->length); + rest_of_page = PAGE_CACHE_SIZE - (sg->offset & (PAGE_CACHE_SIZE - 1)); walk->len_this_page = min(sg->length, rest_of_page); walk->offset = sg->offset; @@ -55,13 +58,17 @@ void scatterwalk_map(struct scatter_walk *walk, int out) walk->data = crypto_kmap(walk->page, out) + walk->offset; } -static void scatterwalk_pagedone(struct scatter_walk *walk, int out, - unsigned int more) +static inline void scatterwalk_unmap(struct scatter_walk *walk, int out) { /* walk->data may be pointing the first byte of the next page; however, we know we transfered at least one byte. So, walk->data - 1 will be a virtual address in the mapped page. */ + crypto_kunmap(walk->data - 1, out); +} +static void scatterwalk_pagedone(struct scatter_walk *walk, int out, + unsigned int more) +{ if (out) flush_dcache_page(walk->page); @@ -81,7 +88,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out, void scatterwalk_done(struct scatter_walk *walk, int out, int more) { - crypto_kunmap(walk->data, out); + scatterwalk_unmap(walk, out); if (walk->len_this_page == 0 || !more) scatterwalk_pagedone(walk, out, more); } @@ -98,7 +105,7 @@ int scatterwalk_copychunks(void *buf, struct scatter_walk *walk, buf += walk->len_this_page; nbytes -= walk->len_this_page; - crypto_kunmap(walk->data, out); + scatterwalk_unmap(walk, out); scatterwalk_pagedone(walk, out, 1); scatterwalk_map(walk, out); } while (nbytes > walk->len_this_page); diff --git a/crypto/scatterwalk.h b/crypto/scatterwalk.h index 6da6c308c16f..02aa56c649b4 100644 --- a/crypto/scatterwalk.h +++ b/crypto/scatterwalk.h @@ -49,6 +49,7 @@ static inline int scatterwalk_across_pages(struct scatter_walk *walk, static inline void scatterwalk_advance(struct scatter_walk *walk, unsigned int nbytes) { + walk->data += nbytes; walk->offset += nbytes; walk->len_this_page -= nbytes; walk->len_this_segment -= nbytes; |
