Commit d349e9be authored by Yuan Can's avatar Yuan Can Committed by Paolo Abeni

net: ena: Fix error handling in ena_init()

The ena_init() won't destroy workqueue created by
create_singlethread_workqueue() when pci_register_driver() failed.
Call destroy_workqueue() when pci_register_driver() failed to prevent the
resource leak.

Fixes: 1738cd3e ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
Acked-by: default avatarShay Agroskin <shayagr@amazon.com>
Link: https://lore.kernel.org/r/20221114025659.124726-1-yuancan@huawei.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 5121197e
...@@ -4543,13 +4543,19 @@ static struct pci_driver ena_pci_driver = { ...@@ -4543,13 +4543,19 @@ static struct pci_driver ena_pci_driver = {
static int __init ena_init(void) static int __init ena_init(void)
{ {
int ret;
ena_wq = create_singlethread_workqueue(DRV_MODULE_NAME); ena_wq = create_singlethread_workqueue(DRV_MODULE_NAME);
if (!ena_wq) { if (!ena_wq) {
pr_err("Failed to create workqueue\n"); pr_err("Failed to create workqueue\n");
return -ENOMEM; return -ENOMEM;
} }
return pci_register_driver(&ena_pci_driver); ret = pci_register_driver(&ena_pci_driver);
if (ret)
destroy_workqueue(ena_wq);
return ret;
} }
static void __exit ena_cleanup(void) static void __exit ena_cleanup(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment