Commit 03957d84 authored by Jakub Kicinski's avatar Jakub Kicinski

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: default avatarJakub Kicinski <kuba@kernel.org>
parent b89fec54
...@@ -1491,10 +1491,8 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb, ...@@ -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, err = skb_copy_bits(skb, rxm->offset + TLS_HEADER_SIZE,
&dctx->iv[iv_offset] + prot->salt_size, &dctx->iv[iv_offset] + prot->salt_size,
prot->iv_size); prot->iv_size);
if (err < 0) { if (err < 0)
kfree(mem); goto exit_free;
return err;
}
memcpy(&dctx->iv[iv_offset], tls_ctx->rx.iv, prot->salt_size); 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); 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, ...@@ -1510,10 +1508,8 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb,
err = skb_to_sgvec(skb, &sgin[1], err = skb_to_sgvec(skb, &sgin[1],
rxm->offset + prot->prepend_size, rxm->offset + prot->prepend_size,
rxm->full_len - prot->prepend_size); rxm->full_len - prot->prepend_size);
if (err < 0) { if (err < 0)
kfree(mem); goto exit_free;
return err;
}
if (n_sgout) { if (n_sgout) {
if (out_iov) { if (out_iov) {
...@@ -1556,7 +1552,7 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb, ...@@ -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 */ /* Release the pages in case iov was mapped to pages */
for (; pages > 0; pages--) for (; pages > 0; pages--)
put_page(sg_page(&sgout[pages])); put_page(sg_page(&sgout[pages]));
exit_free:
kfree(mem); kfree(mem);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment