aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Mueller <smueller@chronox.de>2017-08-10 10:40:03 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2017-08-22 03:03:27 -0400
commit2d45a7e89833f88b38112292ff227af437f81f2f (patch)
treeeccc3beb0adf527562a4ea61d5aafccea919c24a
parent32e67b9af077e905388f1746bf429ea0c39b6917 (diff)
crypto: af_alg - get_page upon reassignment to TX SGL
When a page is assigned to a TX SGL, call get_page to increment the reference counter. It is possible that one page is referenced in multiple SGLs: - in the global TX SGL in case a previous af_alg_pull_tsgl only reassigned parts of a page to a per-request TX SGL - in the per-request TX SGL as assigned by af_alg_pull_tsgl Note, multiple requests can be active at the same time whose TX SGLs all point to different parts of the same page. Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/af_alg.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index d6936c0e08d9..ffa9f4ccd9b4 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -641,9 +641,9 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
641 if (dst_offset >= plen) { 641 if (dst_offset >= plen) {
642 /* discard page before offset */ 642 /* discard page before offset */
643 dst_offset -= plen; 643 dst_offset -= plen;
644 put_page(page);
645 } else { 644 } else {
646 /* reassign page to dst after offset */ 645 /* reassign page to dst after offset */
646 get_page(page);
647 sg_set_page(dst + j, page, 647 sg_set_page(dst + j, page,
648 plen - dst_offset, 648 plen - dst_offset,
649 sg[i].offset + dst_offset); 649 sg[i].offset + dst_offset);
@@ -661,9 +661,7 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
661 if (sg[i].length) 661 if (sg[i].length)
662 return; 662 return;
663 663
664 if (!dst) 664 put_page(page);
665 put_page(page);
666
667 sg_assign_page(sg + i, NULL); 665 sg_assign_page(sg + i, NULL);
668 } 666 }
669 667