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

fm10k: Fix error handling in fm10k_init_module()

stable inclusion
from stable-v5.10.158
commit fd4960ea53625105fb8616096b931a977a63a8e5
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=fd4960ea53625105fb8616096b931a977a63a8e5

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

[ Upstream commit 771a794c ]

A problem about modprobe fm10k failed is triggered with the following log
given:

 Intel(R) Ethernet Switch Host Interface Driver
 Copyright(c) 2013 - 2019 Intel Corporation.
 debugfs: Directory 'fm10k' with parent '/' already present!

The reason is that fm10k_init_module() returns fm10k_register_pci_driver()
directly without checking its return value, if fm10k_register_pci_driver()
failed, it returns without removing debugfs and destroy workqueue,
resulting the debugfs of fm10k can never be created later and leaks the
workqueue.

 fm10k_init_module()
   alloc_workqueue()
   fm10k_dbg_init() # create debugfs
   fm10k_register_pci_driver()
     pci_register_driver()
       driver_register()
         bus_add_driver()
           priv = kzalloc(...) # OOM happened
   # return without remove debugfs and destroy workqueue

Fix by remove debugfs and destroy workqueue when
fm10k_register_pci_driver() returns error.

Fixes: 7461fd91 ("fm10k: Add support for debugfs")
Fixes: b382bb1b ("fm10k: use separate workqueue for fm10k driver")
Signed-off-by: NYuan Can <yuancan@huawei.com>
Reviewed-by: NJacob Keller <jacob.e.keller@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>
上级 7b7cdc73
......@@ -32,6 +32,8 @@ struct workqueue_struct *fm10k_workqueue;
**/
static int __init fm10k_init_module(void)
{
int ret;
pr_info("%s\n", fm10k_driver_string);
pr_info("%s\n", fm10k_copyright);
......@@ -43,7 +45,13 @@ static int __init fm10k_init_module(void)
fm10k_dbg_init();
return fm10k_register_pci_driver();
ret = fm10k_register_pci_driver();
if (ret) {
fm10k_dbg_exit();
destroy_workqueue(fm10k_workqueue);
}
return ret;
}
module_init(fm10k_init_module);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册