]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ixgbevf: Fix resource leak in ixgbevf_init_module()
authorShang XiaoJing <shangxiaojing@huawei.com>
Mon, 14 Nov 2022 02:57:58 +0000 (10:57 +0800)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 13:00:32 +0000 (14:00 +0100)
[ Upstream commit 8cfa238a48f34038464b99d0b4825238c2687181 ]

ixgbevf_init_module() won't destroy the workqueue created by
create_singlethread_workqueue() when pci_register_driver() failed. Add
destroy_workqueue() in fail path to prevent the resource leak.

Similar to the handling of u132_hcd_init in commit f276e002793c
("usb: u132-hcd: fix resource leak")

Fixes: 40a13e2493c9 ("ixgbevf: Use a private workqueue to avoid certain possible hangs")
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
Reviewed-by: Saeed Mahameed <saeed@kernel.org>
Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 7109e941099244cc876a4b3cb7a3ec79f104374a)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

index c2e96e570f3bf4670e28f6f763ca8badb5826b04..cd62fd8892826c84bc5a862894daa32474d5e757 100644 (file)
@@ -4868,6 +4868,8 @@ static struct pci_driver ixgbevf_driver = {
  **/
 static int __init ixgbevf_init_module(void)
 {
+       int err;
+
        pr_info("%s\n", ixgbevf_driver_string);
        pr_info("%s\n", ixgbevf_copyright);
        ixgbevf_wq = create_singlethread_workqueue(ixgbevf_driver_name);
@@ -4876,7 +4878,13 @@ static int __init ixgbevf_init_module(void)
                return -ENOMEM;
        }
 
-       return pci_register_driver(&ixgbevf_driver);
+       err = pci_register_driver(&ixgbevf_driver);
+       if (err) {
+               destroy_workqueue(ixgbevf_wq);
+               return err;
+       }
+
+       return 0;
 }
 
 module_init(ixgbevf_init_module);