[PATCH net] net: ipvlan: check register_netdevice_notifier() error in ipvlan_init_module()

Minhong He <[email protected]>
Newsgroups org.kernel.vger.netdev,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
ipvlan_init_module() ignores register_netdevice_notifier() errors and
continues module initialization, which can leave ipvlan loaded without
its netdev notifier registered.

Check the error and fail module initialization early.

Signed-off-by: Minhong He <[email protected]>
---
 drivers/net/ipvlan/ipvlan_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index ed46439a9f4e..518c7b97deaa 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -1048,7 +1048,9 @@ static int __init ipvlan_init_module(void)
 	int err;
 
 	ipvlan_init_secret();
-	register_netdevice_notifier(&ipvlan_notifier_block);
+	err = register_netdevice_notifier(&ipvlan_notifier_block);
+	if (err)
+		return err;
 #if IS_ENABLED(CONFIG_IPV6)
 	register_inet6addr_notifier(&ipvlan_addr6_notifier_block);
 	register_inet6addr_validator_notifier(
-- 
2.25.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.