tree: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
master
head: bd4d08daeb959234a9f8365037b0fefa6ae790c6
commit: a42055e8d2c30d4decfc13ce943d09c7b9dad221 [207/219] net/tls: Add support
for async encryption of records for performance
smatch warnings:
net/tls/tls_sw.c:885 tls_sw_sendmsg() error: uninitialized symbol 'ret'.
net/tls/tls_sw.c:1014 tls_sw_sendpage() error: uninitialized symbol 'ret'.
#
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=a42055e8d2c30d4decfc13ce943d09c7b9dad221
git remote add net-next
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
git remote update net-next
git checkout a42055e8d2c30d4decfc13ce943d09c7b9dad221
vim +/ret +885 net/tls/tls_sw.c
a42055e8 Vakul Garg 2018-09-21 693
a42055e8 Vakul Garg 2018-09-21 694 int tls_sw_sendmsg(struct sock
*sk, struct msghdr *msg, size_t size)
a42055e8 Vakul Garg 2018-09-21 695 {
3c4d7559 Dave Watson 2017-06-14 696 long timeo = sock_sndtimeo(sk,
msg->msg_flags & MSG_DONTWAIT);
a42055e8 Vakul Garg 2018-09-21 697 struct tls_context *tls_ctx =
tls_get_ctx(sk);
a42055e8 Vakul Garg 2018-09-21 698 struct tls_sw_context_tx *ctx =
tls_sw_ctx_tx(tls_ctx);
a42055e8 Vakul Garg 2018-09-21 699 struct crypto_tfm *tfm =
crypto_aead_tfm(ctx->aead_send);
a42055e8 Vakul Garg 2018-09-21 700 bool async_capable =
tfm->__crt_alg->cra_flags & CRYPTO_ALG_ASYNC;
a42055e8 Vakul Garg 2018-09-21 701 unsigned char record_type =
TLS_RECORD_TYPE_DATA;
a42055e8 Vakul Garg 2018-09-21 702 bool is_kvec =
msg->msg_iter.type & ITER_KVEC;
3c4d7559 Dave Watson 2017-06-14 703 bool eor = !(msg->msg_flags &
MSG_MORE);
3c4d7559 Dave Watson 2017-06-14 704 size_t try_to_copy, copied = 0;
a42055e8 Vakul Garg 2018-09-21 705 struct tls_rec *rec;
a42055e8 Vakul Garg 2018-09-21 706 int required_size;
a42055e8 Vakul Garg 2018-09-21 707 int num_async = 0;
3c4d7559 Dave Watson 2017-06-14 708 bool full_record;
a42055e8 Vakul Garg 2018-09-21 709 int record_room;
a42055e8 Vakul Garg 2018-09-21 710 int num_zc = 0;
3c4d7559 Dave Watson 2017-06-14 711 int orig_size;
a42055e8 Vakul Garg 2018-09-21 712 int ret;
3c4d7559 Dave Watson 2017-06-14 713
3c4d7559 Dave Watson 2017-06-14 714 if (msg->msg_flags & ~(MSG_MORE
| MSG_DONTWAIT | MSG_NOSIGNAL))
3c4d7559 Dave Watson 2017-06-14 715 return -ENOTSUPP;
3c4d7559 Dave Watson 2017-06-14 716
3c4d7559 Dave Watson 2017-06-14 717 lock_sock(sk);
3c4d7559 Dave Watson 2017-06-14 718
a42055e8 Vakul Garg 2018-09-21 719 /* Wait till there is any
pending write on socket */
a42055e8 Vakul Garg 2018-09-21 720 if
(unlikely(sk->sk_write_pending)) {
a42055e8 Vakul Garg 2018-09-21 721 ret =
wait_on_pending_writer(sk, );
a42055e8 Vakul Garg 2018-09-21 722 if (unlikely(ret))
3c4d7559 Dave Watson 2017-06-14 723 goto send_end;
a42055e8 Vakul Garg 2018-09-21 724 }
3c4d7559 Dave Watson 2017-06-14 725
3c4d7559 Dave Watson 2017-06-14 726 if
(unlikely(msg->msg_controllen)) {
3c4d7559 Dave Watson 2017-06-14 727 ret =
tls_proccess_cmsg(sk, msg, _type);
a42055e8 Vakul Garg 2018-09-21 728 if (ret) {
a42055e8 Vakul Garg 2018-09-21 729 if (ret ==
-EINPROGRESS)
a42055e8 Vakul Garg 2018-09-21 730
num_async++;
a42055e8 Vakul Garg 2018-09-21 731 else if (ret !=
-EAGAIN)
3c4d7559 Dave Watson 2017-06-14 732 goto
send_end;
3c4d7559 Dave Watson 2017-06-14 733 }
a42055e8 Vakul Garg 2018-09-21 734 }
3c4d7559 Dave Watson 2017-06-14 735
3c4d7559 Dave Watson 2017-06-14 736 while (msg_data_left(msg)) {
I guess Smatch is complaining that it can't be sure that we always enter
this loop. 50/50 it's a false positive.
3c4d7559 Dave Watson 2017-06-14 737 if (sk->sk_err) {
30be8f8d r.her...@avm.de 2018-01-12 738 ret =
-sk->sk_err;
3c4d7559 Dave Watson 2017-06-14 739 goto send_end;
3c4d7559 Dave Watson 2017-06-14 740 }
3c4d7559 Dave Watson 2017-06-14 741
a42055e8 Vakul Garg 2018-09-21 742 rec = get_rec(sk);
a42055e8 Vakul Garg 2018-09-21 743 if (!rec) {
a42055e8 Vakul Garg 2018-09-21 744 ret = -ENOMEM;
a42055e8 Vakul Garg 2018-09-21 745 goto send_end;