ChangeSet 1.2199.14.29, 2005/03/23 12:10:18-08:00, [EMAIL PROTECTED]
[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 <[EMAIL PROTECTED]>
scatterwalk.c | 15 +++++++++++----
scatterwalk.h | 1 +
2 files changed, 12 insertions(+), 4 deletions(-)
diff -Nru a/crypto/scatterwalk.c b/crypto/scatterwalk.c
--- a/crypto/scatterwalk.c 2005-03-26 17:23:50 -08:00
+++ b/crypto/scatterwalk.c 2005-03-26 17:23:50 -08:00
@@ -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 @@
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 @@
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 @@
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 @@
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 -Nru a/crypto/scatterwalk.h b/crypto/scatterwalk.h
--- a/crypto/scatterwalk.h 2005-03-26 17:23:50 -08:00
+++ b/crypto/scatterwalk.h 2005-03-26 17:23:50 -08:00
@@ -49,6 +49,7 @@
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;
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html