Skip to content

Commit 2d45a7e

Browse files
smuellerDDherbertx
authored andcommitted
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 <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 32e67b9 commit 2d45a7e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

crypto/af_alg.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,9 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
641641
if (dst_offset >= plen) {
642642
/* discard page before offset */
643643
dst_offset -= plen;
644-
put_page(page);
645644
} else {
646645
/* reassign page to dst after offset */
646+
get_page(page);
647647
sg_set_page(dst + j, page,
648648
plen - dst_offset,
649649
sg[i].offset + dst_offset);
@@ -661,9 +661,7 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
661661
if (sg[i].length)
662662
return;
663663

664-
if (!dst)
665-
put_page(page);
666-
664+
put_page(page);
667665
sg_assign_page(sg + i, NULL);
668666
}
669667

0 commit comments

Comments
 (0)