提交 add6077d 编写于 作者: Y Yuan Can 提交者: sanglipeng

iavf: Fix error handling in iavf_init_module()

stable inclusion
from stable-v5.10.158
commit 971c55f0763b480e63ceb7a22beb19be2509e5ed
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=971c55f0763b480e63ceb7a22beb19be2509e5ed

--------------------------------

[ Upstream commit 227d8d2f ]

The iavf_init_module() won't destroy workqueue when pci_register_driver()
failed. Call destroy_workqueue() when pci_register_driver() failed to
prevent the resource leak.

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

Fixes: 2803b16c ("i40e/i40evf: Use private workqueue")
Signed-off-by: NYuan Can <yuancan@huawei.com>
Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
上级 6cd105f3
...@@ -4026,6 +4026,8 @@ static struct pci_driver iavf_driver = { ...@@ -4026,6 +4026,8 @@ static struct pci_driver iavf_driver = {
**/ **/
static int __init iavf_init_module(void) static int __init iavf_init_module(void)
{ {
int ret;
pr_info("iavf: %s\n", iavf_driver_string); pr_info("iavf: %s\n", iavf_driver_string);
pr_info("%s\n", iavf_copyright); pr_info("%s\n", iavf_copyright);
...@@ -4036,7 +4038,12 @@ static int __init iavf_init_module(void) ...@@ -4036,7 +4038,12 @@ static int __init iavf_init_module(void)
pr_err("%s: Failed to create workqueue\n", iavf_driver_name); pr_err("%s: Failed to create workqueue\n", iavf_driver_name);
return -ENOMEM; return -ENOMEM;
} }
return pci_register_driver(&iavf_driver);
ret = pci_register_driver(&iavf_driver);
if (ret)
destroy_workqueue(iavf_wq);
return ret;
} }
module_init(iavf_init_module); module_init(iavf_init_module);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册