Skip to content

Commit

Permalink
crypto: af_alg - get_page upon reassignment to TX SGL
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
smuellerDD authored and herbertx committed Aug 22, 2017
1 parent 32e67b9 commit 2d45a7e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crypto/af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,9 +641,9 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
if (dst_offset >= plen) {
/* discard page before offset */
dst_offset -= plen;
put_page(page);
} else {
/* reassign page to dst after offset */
get_page(page);
sg_set_page(dst + j, page,
plen - dst_offset,
sg[i].offset + dst_offset);
Expand All @@ -661,9 +661,7 @@ void af_alg_pull_tsgl(struct sock *sk, size_t used, struct scatterlist *dst,
if (sg[i].length)
return;

if (!dst)
put_page(page);

put_page(page);
sg_assign_page(sg + i, NULL);
}

Expand Down

0 comments on commit 2d45a7e

Please sign in to comment.