提交 5cb6b7f9 编写于 作者: Y Yuan Can 提交者: openeuler-sync-bot

net: ionic: Fix error handling in ionic_init_module()

stable inclusion
from stable-v5.10.156
commit 2d5a495501352f3df1818c798b0e23bfe4d6e859
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7MCG1

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

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

[ Upstream commit 280c0f7c ]

A problem about ionic create debugfs failed is triggered with the
following log given:

 [  415.799514] debugfs: Directory 'ionic' with parent '/' already present!

The reason is that ionic_init_module() returns ionic_bus_register_driver()
directly without checking its return value, if ionic_bus_register_driver()
failed, it returns without destroy the newly created debugfs, resulting
the debugfs of ionic can never be created later.

 ionic_init_module()
   ionic_debugfs_create() # create debugfs directory
   ionic_bus_register_driver()
     pci_register_driver()
       driver_register()
         bus_add_driver()
           priv = kzalloc(...) # OOM happened
   # return without destroy debugfs directory

Fix by removing debugfs when ionic_bus_register_driver() returns error.

Fixes: fbfb8031 ("ionic: Add hardware init and device commands")
Signed-off-by: NYuan Can <yuancan@huawei.com>
Acked-by: NShannon Nelson <snelson@pensando.io>
Link: https://lore.kernel.org/r/20221113092929.19161-1-yuancan@huawei.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
(cherry picked from commit 4d68064a)
上级 ace8a49a
......@@ -569,8 +569,14 @@ int ionic_port_reset(struct ionic *ionic)
static int __init ionic_init_module(void)
{
int ret;
ionic_debugfs_create();
return ionic_bus_register_driver();
ret = ionic_bus_register_driver();
if (ret)
ionic_debugfs_destroy();
return ret;
}
static void __exit ionic_cleanup_module(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册