[RAMEN9610-8702][COMMON] diskcipher: support f2fs
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / crypto / tcrypt.c
index 0022a18d36eeb461dcc26b11b2439a95460b7747..e339960dcac7ba85e2b7cf92fa221429e10172cf 100644 (file)
@@ -221,11 +221,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,
@@ -340,7 +342,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));
@@ -348,7 +350,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)