crypto: algif_skcipher - sendmsg SG marking is off by one
[firefly-linux-kernel-4.4.55.git] / crypto / algif_skcipher.c
index afb43392524f16d0a8cd1f22ca74af6049605bd4..76175e316e6bd1049d92302c93960ed0dcef04f4 100644 (file)
@@ -392,7 +392,8 @@ static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg,
 
                sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
                sg = sgl->sg;
-               sg_unmark_end(sg + sgl->cur);
+               if (sgl->cur)
+                       sg_unmark_end(sg + sgl->cur - 1);
                do {
                        i = sgl->cur;
                        plen = min_t(int, len, PAGE_SIZE);