Skip to content

Commit

Permalink
net/tls: remove unnecessary jump instructions in do_tls_setsockopt_co…
Browse files Browse the repository at this point in the history
…nf()

Avoid using "goto" jump instruction unconditionally when we
can return directly. Remove unnecessary jump instructions in
do_tls_setsockopt_conf().

Signed-off-by: Ziyang Xuan <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Ziyang Xuan authored and kuba-moo committed Mar 21, 2022
1 parent 351bdbb commit 1ddcbfb
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions net/tls/tls_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,8 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,
int rc = 0;
int conf;

if (sockptr_is_null(optval) || (optlen < sizeof(*crypto_info))) {
rc = -EINVAL;
goto out;
}
if (sockptr_is_null(optval) || (optlen < sizeof(*crypto_info)))
return -EINVAL;

if (tx) {
crypto_info = &ctx->crypto_send.info;
Expand All @@ -567,10 +565,8 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,
}

/* Currently we don't support set crypto info more than one time */
if (TLS_CRYPTO_INFO_READY(crypto_info)) {
rc = -EBUSY;
goto out;
}
if (TLS_CRYPTO_INFO_READY(crypto_info))
return -EBUSY;

rc = copy_from_sockptr(crypto_info, optval, sizeof(*crypto_info));
if (rc) {
Expand Down Expand Up @@ -672,11 +668,10 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,
ctx->sk_write_space = sk->sk_write_space;
sk->sk_write_space = tls_write_space;
}
goto out;
return 0;

err_crypto_info:
memzero_explicit(crypto_info, sizeof(union tls_crypto_context));
out:
return rc;
}

Expand Down

0 comments on commit 1ddcbfb

Please sign in to comment.