Skip to content

Commit

Permalink
crypto: af_alg: Indent the loop in af_alg_sendmsg()
Browse files Browse the repository at this point in the history
Put the loop in af_alg_sendmsg() into an if-statement to indent it to make
the next patch easier to review as that will add another branch to handle
MSG_SPLICE_PAGES to the if-statement.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Herbert Xu <herbert@gondor.apana.org.au>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: Paolo Abeni <pabeni@redhat.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Matthew Wilcox <willy@infradead.org>
cc: linux-crypto@vger.kernel.org
cc: netdev@vger.kernel.org
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
David Howells authored and Paolo Abeni committed Jun 8, 2023
1 parent c1abe6f commit 73d7409
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions crypto/af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,35 +1030,38 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
if (sgl->cur)
sg_unmark_end(sg + sgl->cur - 1);

do {
struct page *pg;
unsigned int i = sgl->cur;
if (1 /* TODO check MSG_SPLICE_PAGES */) {
do {
struct page *pg;
unsigned int i = sgl->cur;

plen = min_t(size_t, len, PAGE_SIZE);
plen = min_t(size_t, len, PAGE_SIZE);

pg = alloc_page(GFP_KERNEL);
if (!pg) {
err = -ENOMEM;
goto unlock;
}
pg = alloc_page(GFP_KERNEL);
if (!pg) {
err = -ENOMEM;
goto unlock;
}

sg_assign_page(sg + i, pg);
sg_assign_page(sg + i, pg);

err = memcpy_from_msg(page_address(sg_page(sg + i)),
msg, plen);
if (err) {
__free_page(sg_page(sg + i));
sg_assign_page(sg + i, NULL);
goto unlock;
}
err = memcpy_from_msg(
page_address(sg_page(sg + i)),
msg, plen);
if (err) {
__free_page(sg_page(sg + i));
sg_assign_page(sg + i, NULL);
goto unlock;
}

sg[i].length = plen;
len -= plen;
ctx->used += plen;
copied += plen;
size -= plen;
sgl->cur++;
} while (len && sgl->cur < MAX_SGL_ENTS);
sg[i].length = plen;
len -= plen;
ctx->used += plen;
copied += plen;
size -= plen;
sgl->cur++;
} while (len && sgl->cur < MAX_SGL_ENTS);
}

if (!size)
sg_mark_end(sg + sgl->cur - 1);
Expand Down

0 comments on commit 73d7409

Please sign in to comment.