Patchwork net: l2tp_eth: fix kernel panic on rmmod l2tp_eth

login
register
mail settings
Submitter Eric Dumazet
Date June 7, 2012, 10:07 a.m.
Message ID <1339063640.26966.113.camel@edumazet-glaptop>
Download mbox | patch
Permalink /patch/163567/
State Accepted
Delegated to: David Miller
Headers show

Comments

Eric Dumazet - June 7, 2012, 10:07 a.m.
From: Eric Dumazet <edumazet@google.com>

We must prevent module unloading if some devices are still attached to
l2tp_eth driver.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Denys Fedoryshchenko <denys@visp.net.lb>
Tested-by: Denys Fedoryshchenko <denys@visp.net.lb>
Cc: James Chapman <jchapman@katalix.com>
---
 net/l2tp/l2tp_eth.c |    2 ++
 1 file changed, 2 insertions(+)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - June 7, 2012, 8:02 p.m.
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 07 Jun 2012 12:07:20 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> We must prevent module unloading if some devices are still attached to
> l2tp_eth driver.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Denys Fedoryshchenko <denys@visp.net.lb>
> Tested-by: Denys Fedoryshchenko <denys@visp.net.lb>
Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 443591d..185f12f 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -162,6 +162,7 @@  static void l2tp_eth_delete(struct l2tp_session *session)
 		if (dev) {
 			unregister_netdev(dev);
 			spriv->dev = NULL;
+			module_put(THIS_MODULE);
 		}
 	}
 }
@@ -249,6 +250,7 @@  static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p
 	if (rc < 0)
 		goto out_del_dev;
 
+	__module_get(THIS_MODULE);
 	/* Must be done after register_netdev() */
 	strlcpy(session->ifname, dev->name, IFNAMSIZ);