summaryrefslogtreecommitdiff
path: root/drivers/net/ntb_netdev.c
diff options
context:
space:
mode:
authorYuan Can <yuancan@huawei.com>2022-11-24 10:09:17 +0300
committerDavid S. Miller <davem@davemloft.net>2022-11-28 14:07:13 +0300
commitb8f79dccd38edf7db4911c353d9cd792ab13a327 (patch)
tree1689e2fa6b57ff4daaa7e710658ad0b08bd65faa /drivers/net/ntb_netdev.c
parent46fb6512538d201d9a5b2bd7138b6751c37fdf0b (diff)
downloadlinux-b8f79dccd38edf7db4911c353d9cd792ab13a327.tar.xz
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. Fixes: 548c237c0a99 ("net: Add support for NTB virtual ethernet device") Signed-off-by: Yuan Can <yuancan@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ntb_netdev.c')
-rw-r--r--drivers/net/ntb_netdev.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
index 464d88ca8ab0..a4abea921046 100644
--- a/drivers/net/ntb_netdev.c
+++ b/drivers/net/ntb_netdev.c
@@ -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);