diff options
author | Jakub Kicinski | 2022-07-07 18:03:12 -0700 |
---|---|---|
committer | Jakub Kicinski | 2022-07-08 18:38:45 -0700 |
commit | 03957d84055e59235c7d57c95a37617bd3aa5646 (patch) | |
tree | ce0e5887303fa4a3ee4cfa160f5365d3abfe8c76 /net/tls | |
parent | b89fec54fd614ffa4b7567edfae8b9e56c07ff69 (diff) |
tls: rx: coalesce exit paths in tls_decrypt_sg()
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>
Diffstat (limited to 'net/tls')
-rw-r--r-- | net/tls/tls_sw.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 5965649362a5..21c76db8f9b3 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -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); @@ -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) { @@ -1556,7 +1552,7 @@ fallback_to_reg_recv: /* 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; } |