WAN: protect HDLC proto list while insmod/rmmod
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>
This commit is contained in:
committed by
Jeff Garzik
parent
4ecc8c066f
commit
fa701bd24d
@ -43,8 +43,7 @@ static const char* version = "HDLC support module revision 1.22";
|
|||||||
|
|
||||||
#undef DEBUG_LINK
|
#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)
|
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)
|
void register_hdlc_protocol(struct hdlc_proto *proto)
|
||||||
{
|
{
|
||||||
|
rtnl_lock();
|
||||||
proto->next = first_proto;
|
proto->next = first_proto;
|
||||||
first_proto = proto;
|
first_proto = proto;
|
||||||
|
rtnl_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void unregister_hdlc_protocol(struct hdlc_proto *proto)
|
void unregister_hdlc_protocol(struct hdlc_proto *proto)
|
||||||
{
|
{
|
||||||
struct hdlc_proto **p = &first_proto;
|
struct hdlc_proto **p;
|
||||||
while (*p) {
|
|
||||||
if (*p == proto) {
|
rtnl_lock();
|
||||||
*p = proto->next;
|
p = &first_proto;
|
||||||
return;
|
while (*p != proto) {
|
||||||
}
|
BUG_ON(!*p);
|
||||||
p = &((*p)->next);
|
p = &((*p)->next);
|
||||||
}
|
}
|
||||||
|
*p = proto->next;
|
||||||
|
rtnl_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user