net: hinic: Fix error handling in hinic_module_init()
A problem about hinic create debugfs failed is triggered with the
following log given:
[ 931.419023] debugfs: Directory 'hinic' with parent '/' already present!
The reason is that hinic_module_init() returns pci_register_driver()
directly without checking its return value, if pci_register_driver()
failed, it returns without destroy the newly created debugfs, resulting
the debugfs of hinic can never be created later.
hinic_module_init()
hinic_dbg_register_debugfs() # create debugfs directory
pci_register_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when pci_register_driver() returns error.
Fixes: 253ac3a979
("hinic: add support to query sq info")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20221110021642.80378-1-yuancan@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Родитель
98a2ac1ca8
Коммит
8eab9be56c
|
@ -1474,8 +1474,15 @@ static struct pci_driver hinic_driver = {
|
|||
|
||||
static int __init hinic_module_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
hinic_dbg_register_debugfs(HINIC_DRV_NAME);
|
||||
return pci_register_driver(&hinic_driver);
|
||||
|
||||
ret = pci_register_driver(&hinic_driver);
|
||||
if (ret)
|
||||
hinic_dbg_unregister_debugfs();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit hinic_module_exit(void)
|
||||
|
|
Загрузка…
Ссылка в новой задаче