From d3b7f69de2b92e4b6057d81e6c52f629a8663368 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Sat, 10 Feb 2007 01:43:56 -0800 Subject: [PATCH] uml: add locking to network transport registration The registration of host network transports needed some locking. The transport list itself is locked, but calls to the registration routines are not. This is compensated for by checking that a transport structure is not yet on any list. I also took the opportunity to const all fields in the transport structure except the list, which obviously can be modified. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/net_kern.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'arch/um/drivers/net_kern.c') diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 07e839e387db..b10154cc46b6 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c @@ -498,10 +498,8 @@ struct eth_init { int index; }; -/* Filled in at boot time. Will need locking if the transports become - * modular. - */ -struct list_head transports = LIST_HEAD_INIT(transports); +static DEFINE_SPINLOCK(transports_lock); +static LIST_HEAD(transports); /* Filled in during early boot */ struct list_head eth_cmd_line = LIST_HEAD_INIT(eth_cmd_line); @@ -540,7 +538,10 @@ void register_transport(struct transport *new) char *mac = NULL; int match; + spin_lock(&transports_lock); + BUG_ON(!list_empty(&new->list)); list_add(&new->list, &transports); + spin_unlock(&transports_lock); list_for_each_safe(ele, next, ð_cmd_line){ eth = list_entry(ele, struct eth_init, list); -- cgit v1.2.3