* [PATCH] nvme-tcp: Fix a memory leak
@ 2023-10-29 21:22 Christophe JAILLET
2023-10-30 13:29 ` Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2023-10-29 21:22 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>
---
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..3c35c37112e6 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1429,7 +1429,8 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue)
if (ctype != TLS_RECORD_TYPE_DATA) {
pr_err("queue %d: unhandled TLS record %d\n",
nvme_tcp_queue_id(queue), ctype);
- return -ENOTCONN;
+ ret = -ENOTCONN;
+ goto free_icresp;
}
}
ret = -EINVAL;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme-tcp: Fix a memory leak
2023-10-29 21:22 [PATCH] nvme-tcp: Fix a memory leak Christophe JAILLET
@ 2023-10-30 13:29 ` Christoph Hellwig
2023-10-31 7:09 ` Hannes Reinecke
2023-11-20 13:50 ` Sagi Grimberg
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2023-10-30 13:29 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Hannes Reinecke, linux-kernel, kernel-janitors, linux-nvme
On Sun, Oct 29, 2023 at 10:22:57PM +0100, Christophe JAILLET wrote:
> if (ctype != TLS_RECORD_TYPE_DATA) {
> pr_err("queue %d: unhandled TLS record %d\n",
> nvme_tcp_queue_id(queue), ctype);
> - return -ENOTCONN;
> + ret = -ENOTCONN;
> + goto free_icresp;
> }
> }
> ret = -EINVAL;
I'd slightly prefer the code to be consistent how it assigns to err,
and use the style where it is assigned in the main path as with the
-EINVAL for the next checks.
Except for that this looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme-tcp: Fix a memory leak
2023-10-29 21:22 [PATCH] nvme-tcp: Fix a memory leak Christophe JAILLET
2023-10-30 13:29 ` Christoph Hellwig
@ 2023-10-31 7:09 ` Hannes Reinecke
2023-11-20 13:50 ` Sagi Grimberg
2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2023-10-31 7:09 UTC (permalink / raw)
To: Christophe JAILLET, Keith Busch, Jens Axboe, Christoph Hellwig,
Sagi Grimberg
Cc: linux-kernel, kernel-janitors, linux-nvme
On 10/29/23 22:22, 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>
> ---
> 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..3c35c37112e6 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -1429,7 +1429,8 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue)
> if (ctype != TLS_RECORD_TYPE_DATA) {
> pr_err("queue %d: unhandled TLS record %d\n",
> nvme_tcp_queue_id(queue), ctype);
> - return -ENOTCONN;
> + ret = -ENOTCONN;
> + goto free_icresp;
> }
> }
> ret = -EINVAL;
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme-tcp: Fix a memory leak
2023-10-29 21:22 [PATCH] nvme-tcp: Fix a memory leak Christophe JAILLET
2023-10-30 13:29 ` Christoph Hellwig
2023-10-31 7:09 ` Hannes Reinecke
@ 2023-11-20 13:50 ` Sagi Grimberg
2 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2023-11-20 13:50 UTC (permalink / raw)
To: Christophe JAILLET, Keith Busch, Jens Axboe, Christoph Hellwig,
Hannes Reinecke
Cc: linux-kernel, kernel-janitors, linux-nvme
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:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-29 21:22 [PATCH] nvme-tcp: Fix a memory leak Christophe JAILLET
2023-10-30 13:29 ` Christoph Hellwig
2023-10-31 7:09 ` Hannes Reinecke
2023-11-20 13:50 ` Sagi Grimberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox