From: Yuan Can Date: Thu, 24 Nov 2022 07:09:17 +0000 (+0000) Subject: net: net_netdev: Fix error handling in ntb_netdev_init_module() X-Git-Tag: v5.15.92~1695 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6fc9425bff4b77c489b151392283251bc3078b47;p=platform%2Fkernel%2Flinux-rpi.git net: net_netdev: Fix error handling in ntb_netdev_init_module() [ Upstream commit b8f79dccd38edf7db4911c353d9cd792ab13a327 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c index a5bab614..1b7d588 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);