[PATCH v2] nvme-tcp: fix connect failure on receiving partial ICResp PDU

Maurizio Lombardi mlombard at redhat.com
Fri Jan 24 00:08:42 PST 2025


čt 23. 1. 2025 v 23:50 odesílatel Caleb Sander Mateos
<csander at purestorage.com> napsal:
>
>         ret = kernel_recvmsg(queue->sock, &msg, &iov, 1,
>                         iov.iov_len, msg.msg_flags);
> -       if (ret < 0) {
> +       if (ret < sizeof(*icresp)) {
>                 pr_warn("queue %d: failed to receive icresp, error %d\n",
>                         nvme_tcp_queue_id(queue), ret);
>                 goto free_icresp;
>         }

There is a small problem here, suppose ret is a positive number but
smaller than sizeof(*icresp),
you will print a bogus error code, then you "goto free_icresp;" and
return this random positive number to the caller.

I think that if ret > 0 you should set it to -EINVAL.

Maurizio




More information about the Linux-nvme mailing list