OSDN Git Service

NFC: pn544: Adjust indentation in pn544_hci_check_presence
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / crypto / tcrypt.c
index 46a4a75..1d92b5d 100644 (file)
@@ -291,11 +291,13 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
        }
 
        sg_init_table(sg, np + 1);
-       np--;
+       if (rem)
+               np--;
        for (k = 0; k < np; k++)
                sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE);
 
-       sg_set_buf(&sg[k + 1], xbuf[k], rem);
+       if (rem)
+               sg_set_buf(&sg[k + 1], xbuf[k], rem);
 }
 
 static void test_aead_speed(const char *algo, int enc, unsigned int secs,
@@ -410,7 +412,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
                        }
 
                        sg_init_aead(sg, xbuf,
-                                   *b_size + (enc ? authsize : 0));
+                                   *b_size + (enc ? 0 : authsize));
 
                        sg_init_aead(sgout, xoutbuf,
                                    *b_size + (enc ? authsize : 0));
@@ -418,7 +420,9 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
                        sg_set_buf(&sg[0], assoc, aad_size);
                        sg_set_buf(&sgout[0], assoc, aad_size);
 
-                       aead_request_set_crypt(req, sg, sgout, *b_size, iv);
+                       aead_request_set_crypt(req, sg, sgout,
+                                              *b_size + (enc ? 0 : authsize),
+                                              iv);
                        aead_request_set_ad(req, aad_size);
 
                        if (secs)