]> err.no Git - linux-2.6/commitdiff
WAN: protect HDLC proto list while insmod/rmmod
authorKrzysztof Halasa <khc@pm.waw.pl>
Mon, 19 May 2008 17:00:51 +0000 (19:00 +0200)
committerJeff Garzik <jgarzik@redhat.com>
Thu, 22 May 2008 10:26:32 +0000 (06:26 -0400)
WAN: protect protocol list in hdlc.c with RTNL.

Signed-off-by: Krzysztof HaƂasa <khc@pm.waw.pl>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/net/wan/hdlc.c

index 9a83c9d5b8cfe89cffd2b99a234f594018fb7e09..7f984895b0d53efbcada5adaf6f8a625dc9be9f0 100644 (file)
@@ -43,8 +43,7 @@ static const char* version = "HDLC support module revision 1.22";
 
 #undef DEBUG_LINK
 
-static struct hdlc_proto *first_proto = NULL;
-
+static struct hdlc_proto *first_proto;
 
 static int hdlc_change_mtu(struct net_device *dev, int new_mtu)
 {
@@ -314,21 +313,25 @@ void detach_hdlc_protocol(struct net_device *dev)
 
 void register_hdlc_protocol(struct hdlc_proto *proto)
 {
+       rtnl_lock();
        proto->next = first_proto;
        first_proto = proto;
+       rtnl_unlock();
 }
 
 
 void unregister_hdlc_protocol(struct hdlc_proto *proto)
 {
-       struct hdlc_proto **p = &first_proto;
-       while (*p) {
-               if (*p == proto) {
-                       *p = proto->next;
-                       return;
-               }
+       struct hdlc_proto **p;
+
+       rtnl_lock();
+       p = &first_proto;
+       while (*p != proto) {
+               BUG_ON(!*p);
                p = &((*p)->next);
        }
+       *p = proto->next;
+       rtnl_unlock();
 }