* Re: [PATCH v3] nbd: Fix memory leak in nbd_add_socket
[not found] <20200622112001.105047-1-zhengbin13@huawei.com>
@ 2020-06-22 14:25 ` Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2020-06-22 14:25 UTC (permalink / raw)
To: Zheng Bin, Navid Emamdoost, linux-block
Cc: nbd, linux-kernel, kernel-janitors, Aditya Pakki,
Navid Emamdoost, Kangjie Lu, Stephen McCamant, Qiushi Wu,
Jens Axboe, Josef Bacik, Tuomas Tynkkynen, Yi Zhang
> When adding first socket to nbd,
…
Can the term “network block device” matter for this change description?
> … A memory leak will occur
> then because the function "nbd_config_put" will free "config->socks" only
> when "config->num_connections" is not zero.
Will an additional imperative wording be helpful for the commit message?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=625d3449788f85569096780592549d0340e9c0c7#n151
Regards,
Markus
…
> +++ b/drivers/block/nbd.c
> @@ -1033,25 +1033,26 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
…
> + if (!nsock) {
> + err = -ENOMEM;
> + goto put_socket;
> }
…
> return 0;
> +
I find that the exception handling can be improved a bit more
by adding another jump target.
+e_nomem:
+ err = -ENOMEM;
> +put_socket:
> + sockfd_put(sock);
> + return err;
> }
Would you like to apply any further fine-tuning?
Regards,
Markus
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-22 14:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20200622112001.105047-1-zhengbin13@huawei.com>
2020-06-22 14:25 ` [PATCH v3] nbd: Fix memory leak in nbd_add_socket Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).