net: net_netdev: Fix error handling in ntb_netdev_init_module()
Subsystems (3)
PATCH 1/1 net: net_netdev: Fix error handling in ntb_netdev_init_module()
The ntb_netdev_init_module() returns the ntb_transport_register_client() directly without checking its return value, if ntb_transport_register_client() failed, the NTB client device is not unregistered.
Fix by unregister NTB client device when ntb_transport_register_client() failed.
--- drivers/net/ntb_netdev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ntb_netdev.c +8 -1
@@ -484,7 +484,14 @@ static int __init ntb_netdev_init_module(void) rc =ntb_transport_register_client_dev (KBUILD_MODNAME );if (rc)return rc; -return ntb_transport_register_client (&ntb_netdev_client); + + rc =ntb_transport_register_client (&ntb_netdev_client); +if (rc) { +ntb_transport_unregister_client_dev (KBUILD_MODNAME ); +return rc; + } + +return 0 ; }module_init (ntb_netdev_init_module);
Signature · 1 line
2.17.1
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Thu, 24 Nov 2022 07:09:17 +0000 you wrote:
The
ntb_netdev_init_module()returns thentb_transport_register_client()directly without checking its return value, ifntb_transport_register_client()failed, the NTB client device is not unregistered.Fix by unregister NTB client device when
ntb_transport_register_client()failed.[...]
Here is the summary with links:
- net: net_netdev: Fix error handling in ntb_netdev_init_module()
https://git.kernel.org/netdev/net/c/b8f79dccd38e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 10 lines · Yuan Can
The
ntb_netdev_init_module()returns thentb_transport_register_client()directly without checking its return value, ifntb_transport_register_client()failed, the NTB client device is not unregistered.Fix by unregister NTB client device when
ntb_transport_register_client()failed.Fixes 548c237c0a99 ("net: Add support for NTB virtual ethernet device")Signed-off-by Yuan Can <[email protected]>
Quoted 24 lines
--- drivers/net/ntb_netdev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/net/ntb_netdev.c +8
-1@@ -484,7 +484,14 @@ static int __init ntb_netdev_init_module(void) rc =ntb_transport_register_client_dev (KBUILD_MODNAME );if (rc)return rc; -return ntb_transport_register_client (&ntb_netdev_client); + + rc =ntb_transport_register_client (&ntb_netdev_client); +if (rc) { +ntb_transport_unregister_client_dev (KBUILD_MODNAME ); +return rc; + } + +return 0 ; }module_init (ntb_netdev_init_module);