[PATCH 1/1] net: ena_netdev: fix resource leak
From: Xiaohui Zhang
Date: Tue Jun 07 2022 - 08:28:50 EST
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@xxxxxxxxxx>
---
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