From: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>
To: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>,
Shay Agroskin <shayagr@amazon.com>,
Arthur Kiyanovski <akiyano@amazon.com>,
David Arinzon <darinzon@amazon.com>,
Noam Dagan <ndagan@amazon.com>, Saeed Bishara <saeedb@amazon.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Sameeh Jubran <sameehj@amazon.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] net: ena_netdev: fix resource leak
Date: Tue, 7 Jun 2022 20:28:31 +0800 [thread overview]
Message-ID: <20220607122831.32738-1-xiaohuizhang@ruc.edu.cn> (raw)
Similar to the handling of u132_hcd_init in commit f276e002793c
("usb: u132-hcd: fix resource leak"), we thought a patch might be
needed here as well.
If platform_driver_register fails, cleanup the allocated resource
gracefully.
Signed-off-by: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 6a356a6cee15..c0624ee8d867 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -4545,13 +4545,17 @@ static struct pci_driver ena_pci_driver = {
static int __init ena_init(void)
{
+ int retval;
ena_wq = create_singlethread_workqueue(DRV_MODULE_NAME);
if (!ena_wq) {
pr_err("Failed to create workqueue\n");
return -ENOMEM;
}
+ retval = pci_register_driver(&ena_pci_driver);
+ if (retval)
+ destroy_workqueue(ena_wq);
- return pci_register_driver(&ena_pci_driver);
+ return retval;
}
static void __exit ena_cleanup(void)
--
2.17.1
next reply other threads:[~2022-06-07 12:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 12:28 Xiaohui Zhang [this message]
2022-06-07 18:57 ` [PATCH 1/1] net: ena_netdev: fix resource leak Shay Agroskin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220607122831.32738-1-xiaohuizhang@ruc.edu.cn \
--to=xiaohuizhang@ruc.edu.cn \
--cc=akiyano@amazon.com \
--cc=darinzon@amazon.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ndagan@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedb@amazon.com \
--cc=sameehj@amazon.com \
--cc=shayagr@amazon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).