Skip to content

Commit

Permalink
tls: rx: coalesce exit paths in tls_decrypt_sg()
Browse files Browse the repository at this point in the history
Jump to the free() call, instead of having to remember
to free the memory in multiple places.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jul 9, 2022
1 parent b89fec5 commit 03957d8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions net/tls/tls_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,10 +1491,8 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb,
err = skb_copy_bits(skb, rxm->offset + TLS_HEADER_SIZE,
&dctx->iv[iv_offset] + prot->salt_size,
prot->iv_size);
if (err < 0) {
kfree(mem);
return err;
}
if (err < 0)
goto exit_free;
memcpy(&dctx->iv[iv_offset], tls_ctx->rx.iv, prot->salt_size);
}
xor_iv_with_seq(prot, &dctx->iv[iv_offset], tls_ctx->rx.rec_seq);
Expand All @@ -1510,10 +1508,8 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb,
err = skb_to_sgvec(skb, &sgin[1],
rxm->offset + prot->prepend_size,
rxm->full_len - prot->prepend_size);
if (err < 0) {
kfree(mem);
return err;
}
if (err < 0)
goto exit_free;

if (n_sgout) {
if (out_iov) {
Expand Down Expand Up @@ -1556,7 +1552,7 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb,
/* Release the pages in case iov was mapped to pages */
for (; pages > 0; pages--)
put_page(sg_page(&sgout[pages]));

exit_free:
kfree(mem);
return err;
}
Expand Down

0 comments on commit 03957d8

Please sign in to comment.