[PATCH net] net: lapbether: check register_netdevice_notifier() error in lapbeth_init_driver()

Minhong He <[email protected]>
Newsgroups org.kernel.vger.netdev,org.kernel.vger.linux-kernel,org.kernel.vger.linux-x25
Message-ID <[email protected]>
lapbeth_init_driver() ignores register_netdevice_notifier() errors and
always returns success, which can leave the module loaded without its
netdev notifier registered.

Check the error and remove the packet type on failure.

Signed-off-by: Minhong He <[email protected]>
---
 drivers/net/wan/lapbether.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index 9861c99ea56c..c3630a82913b 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -497,9 +497,15 @@ static const char banner[] __initconst =
 
 static int __init lapbeth_init_driver(void)
 {
+	int err;
+
 	dev_add_pack(&lapbeth_packet_type);
 
-	register_netdevice_notifier(&lapbeth_dev_notifier);
+	err = register_netdevice_notifier(&lapbeth_dev_notifier);
+	if (err) {
+		dev_remove_pack(&lapbeth_packet_type);
+		return err;
+	}
 
 	printk(banner);
 
-- 
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.