]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - crypto/tcrypt.c
um: Remove broken highmem support
[karo-tx-linux.git] / crypto / tcrypt.c
index 004349576ba13ab98d0e24f68c2ad94863e613c7..4b9e23fa42045d42fae1229f7cc9c9887ca4a275 100644 (file)
@@ -250,19 +250,19 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
        int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
        int k, rem;
 
-       np = (np > XBUFSIZE) ? XBUFSIZE : np;
-       rem = buflen % PAGE_SIZE;
        if (np > XBUFSIZE) {
                rem = PAGE_SIZE;
                np = XBUFSIZE;
+       } else {
+               rem = buflen % PAGE_SIZE;
        }
+
        sg_init_table(sg, np);
-       for (k = 0; k < np; ++k) {
-               if (k == (np-1))
-                       sg_set_buf(&sg[k], xbuf[k], rem);
-               else
-                       sg_set_buf(&sg[k], xbuf[k], PAGE_SIZE);
-       }
+       np--;
+       for (k = 0; k < np; k++)
+               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,
@@ -280,16 +280,20 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
        struct scatterlist *sgout;
        const char *e;
        void *assoc;
-       char iv[MAX_IVLEN];
+       char *iv;
        char *xbuf[XBUFSIZE];
        char *xoutbuf[XBUFSIZE];
        char *axbuf[XBUFSIZE];
        unsigned int *b_size;
        unsigned int iv_len;
 
+       iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
+       if (!iv)
+               return;
+
        if (aad_size >= PAGE_SIZE) {
                pr_err("associate data length (%u) too big\n", aad_size);
-               return;
+               goto out_noxbuf;
        }
 
        if (enc == ENCRYPT)
@@ -355,7 +359,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 
                        iv_len = crypto_aead_ivsize(tfm);
                        if (iv_len)
-                               memset(&iv, 0xff, iv_len);
+                               memset(iv, 0xff, iv_len);
 
                        crypto_aead_clear_flags(tfm, ~0);
                        printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",
@@ -408,6 +412,7 @@ out_nooutbuf:
 out_noaxbuf:
        testmgr_free_buf(xbuf);
 out_noxbuf:
+       kfree(iv);
        return;
 }