[PATCH] batman-adv/main: Fix check on return value of rtnl_link_register

Subsystems: batman advanced, the rest

STALE2814d

3 messages, 2 authors, 2018-12-24 · open the first message on its own page

[PATCH] batman-adv/main: Fix check on return value of rtnl_link_register

From: Aditya Pakki <hidden>
Date: 2018-12-24 17:49:41

rtnl_link_register() may fail and can impact registering the device.
The fix checks the return value and pushes the error upstream.

Signed-off-by: Aditya Pakki <redacted>
---
 net/batman-adv/main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 69c0d85bceb3..e0007f242823 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -109,7 +109,10 @@ static int __init batadv_init(void)
 	batadv_debugfs_init();
 
 	register_netdevice_notifier(&batadv_hard_if_notifier);
-	rtnl_link_register(&batadv_link_ops);
+	ret = rtnl_link_register(&batadv_link_ops);
+	if (ret < 0)
+		return ret;
+
 	batadv_netlink_register();
 
 	pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
-- 
2.17.1

Re: [B.A.T.M.A.N.] [PATCH] batman-adv/main: Fix check on return value of rtnl_link_register

From: Sven Eckelmann <sven@narfation.org>
Date: 2018-12-24 18:43:15

On Monday, 24 December 2018 18.49.26 CET Aditya Pakki wrote:
[...]
quoted hunk
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 69c0d85bceb3..e0007f242823 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -109,7 +109,10 @@ static int __init batadv_init(void)
 	batadv_debugfs_init();
 
 	register_netdevice_notifier(&batadv_hard_if_notifier);
-	rtnl_link_register(&batadv_link_ops);
+	ret = rtnl_link_register(&batadv_link_ops);
+	if (ret < 0)
+		return ret;
+
 	batadv_netlink_register();
Uhm, but shouldn't the already initialized parts be unregistered/uninitialized 
in this case?

Rejecting this patch because this could cause a new bug.

Also "Fixes: " line is missing

Kind regards,
	Sven

Re: [B.A.T.M.A.N.] [PATCH] batman-adv/main: Fix check on return value of rtnl_link_register

From: Sven Eckelmann <sven@narfation.org>
Date: 2018-12-24 18:46:38

On Monday, 24 December 2018 18.49.26 CET Aditya Pakki wrote:
rtnl_link_register() may fail and can impact registering the device.
The fix checks the return value and pushes the error upstream.
Regarding the commit message - what is "batman-adv/main"? Shouldn't this be 
"batman-adv: "?

And the device can still be registered without batadv_link_ops - just not 
using rtnl.

Kind regards,
	Sven
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help