]> git.itanic.dy.fi Git - linux-stable/commitdiff
nvme-tcp: Fix a memory leak
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 30 Oct 2023 14:49:28 +0000 (15:49 +0100)
committerKeith Busch <kbusch@kernel.org>
Mon, 6 Nov 2023 16:05:53 +0000 (08:05 -0800)
All error handling path end to the error handling path, except this one.
Go to the error handling branch as well here, otherwise 'icreq' and
'icresp' will leak.

Fixes: 2837966ab2a8 ("nvme-tcp: control message handling for recvmsg()")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/tcp.c

index 4714a902f4caa8ac30a9f3091b4011fd5e7df5e7..f97711fc9f9fdaef6722a2afe00d7481ff0c751e 100644 (file)
@@ -1423,13 +1423,14 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue)
                        nvme_tcp_queue_id(queue), ret);
                goto free_icresp;
        }
+       ret = -ENOTCONN;
        if (queue->ctrl->ctrl.opts->tls) {
                ctype = tls_get_record_type(queue->sock->sk,
                                            (struct cmsghdr *)cbuf);
                if (ctype != TLS_RECORD_TYPE_DATA) {
                        pr_err("queue %d: unhandled TLS record %d\n",
                               nvme_tcp_queue_id(queue), ctype);
-                       return -ENOTCONN;
+                       goto free_icresp;
                }
        }
        ret = -EINVAL;