aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-02-07 15:58:42 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-07 19:12:32 -0500
commit14d9ead05ec925f299ae5cfe948c180c88ec842e (patch)
tree88901eee9fb3d4b332b8cf96ffd91d0f9cbe2d2f /arch/um/drivers
parent1d2ddcfb1935c9c0e98c4295458b01f24e3274f9 (diff)
[PATCH] uml: balance list_add and list_del in the network driver
The network driver added an interface to the "opened" list when it was configured, not when it was brought up, and removed it when it was taken down. A sequence of ifconfig up, ifconfig down, ... caused it to be removed multiple times from the list without being added in between, resulting in a crash. This patch moves the add to when the interface is brought up. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/drivers')
-rw-r--r--arch/um/drivers/net_kern.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 8ebb2241ad4..8c7279bb353 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -131,9 +131,8 @@ static int uml_net_open(struct net_device *dev)
131 SA_INTERRUPT | SA_SHIRQ, dev->name, dev); 131 SA_INTERRUPT | SA_SHIRQ, dev->name, dev);
132 if(err != 0){ 132 if(err != 0){
133 printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err); 133 printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err);
134 if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
135 lp->fd = -1;
136 err = -ENETUNREACH; 134 err = -ENETUNREACH;
135 goto out_close;
137 } 136 }
138 137
139 lp->tl.data = (unsigned long) &lp->user; 138 lp->tl.data = (unsigned long) &lp->user;
@@ -145,9 +144,19 @@ static int uml_net_open(struct net_device *dev)
145 */ 144 */
146 while((err = uml_net_rx(dev)) > 0) ; 145 while((err = uml_net_rx(dev)) > 0) ;
147 146
148 out:
149 spin_unlock(&lp->lock); 147 spin_unlock(&lp->lock);
150 return(err); 148
149 spin_lock(&opened_lock);
150 list_add(&lp->list, &opened);
151 spin_unlock(&opened_lock);
152
153 return 0;
154out_close:
155 if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
156 lp->fd = -1;
157out:
158 spin_unlock(&lp->lock);
159 return err;
151} 160}
152 161
153static int uml_net_close(struct net_device *dev) 162static int uml_net_close(struct net_device *dev)
@@ -161,9 +170,13 @@ static int uml_net_close(struct net_device *dev)
161 if(lp->close != NULL) 170 if(lp->close != NULL)
162 (*lp->close)(lp->fd, &lp->user); 171 (*lp->close)(lp->fd, &lp->user);
163 lp->fd = -1; 172 lp->fd = -1;
164 list_del(&lp->list);
165 173
166 spin_unlock(&lp->lock); 174 spin_unlock(&lp->lock);
175
176 spin_lock(&opened_lock);
177 list_del(&lp->list);
178 spin_unlock(&opened_lock);
179
167 return 0; 180 return 0;
168} 181}
169 182
@@ -410,11 +423,7 @@ static int eth_configure(int n, void *init, char *mac,
410 if (device->have_mac) 423 if (device->have_mac)
411 set_ether_mac(dev, device->mac); 424 set_ether_mac(dev, device->mac);
412 425
413 spin_lock(&opened_lock); 426 return 0;
414 list_add(&lp->list, &opened);
415 spin_unlock(&opened_lock);
416
417 return(0);
418} 427}
419 428
420static struct uml_net *find_device(int n) 429static struct uml_net *find_device(int n)