* [PATCH v2] nvme-tcp: Fix a memory leak
@ 2023-10-30 14:49 Christophe JAILLET
2023-10-30 14:52 ` Christoph Hellwig
2023-10-30 15:02 ` Keith Busch
0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2023-10-30 14:49 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Hannes Reinecke
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-nvme
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>
---
v2: - move ret = -xx; to the main path [Christoph Hellwig]
- Add R-b tag
v1: https://lore.kernel.org/all/f9420cde9afdc5af40bf8a8d5aa9184a9b5da729.1698614556.git.christophe.jaillet@wanadoo.fr/
Personally I prefer v1. Pick the one you prefer :)
---
drivers/nvme/host/tcp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 4714a902f4ca..f97711fc9f9f 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] nvme-tcp: Fix a memory leak
2023-10-30 14:49 [PATCH v2] nvme-tcp: Fix a memory leak Christophe JAILLET
@ 2023-10-30 14:52 ` Christoph Hellwig
2023-11-20 13:52 ` Sagi Grimberg
2023-10-30 15:02 ` Keith Busch
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2023-10-30 14:52 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Hannes Reinecke, linux-kernel, kernel-janitors, linux-nvme
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
> Personally I prefer v1. Pick the one you prefer :)
I think we should be consistent with one style or another in a
given function. Otherwise I wouldn't even have mentioned it.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] nvme-tcp: Fix a memory leak
2023-10-30 14:49 [PATCH v2] nvme-tcp: Fix a memory leak Christophe JAILLET
2023-10-30 14:52 ` Christoph Hellwig
@ 2023-10-30 15:02 ` Keith Busch
1 sibling, 0 replies; 4+ messages in thread
From: Keith Busch @ 2023-10-30 15:02 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Jens Axboe, Christoph Hellwig, Sagi Grimberg, Hannes Reinecke,
linux-kernel, kernel-janitors, linux-nvme
On Mon, Oct 30, 2023 at 03:49:28PM +0100, Christophe JAILLET wrote:
> 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>
Thanks, applied to nvme-6.7.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] nvme-tcp: Fix a memory leak
2023-10-30 14:52 ` Christoph Hellwig
@ 2023-11-20 13:52 ` Sagi Grimberg
0 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2023-11-20 13:52 UTC (permalink / raw)
To: Christoph Hellwig, Christophe JAILLET
Cc: Keith Busch, Jens Axboe, Hannes Reinecke, linux-kernel,
kernel-janitors, linux-nvme
> Looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
>> Personally I prefer v1. Pick the one you prefer :)
>
> I think we should be consistent with one style or another in a
> given function. Otherwise I wouldn't even have mentioned it.
This looks good too:
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-20 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 14:49 [PATCH v2] nvme-tcp: Fix a memory leak Christophe JAILLET
2023-10-30 14:52 ` Christoph Hellwig
2023-11-20 13:52 ` Sagi Grimberg
2023-10-30 15:02 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox