[ATM]: avoid race conditions related to atm_devs list
Use semaphore to protect atm_devs list, as no one need access to it from interrupt context. Avoid race conditions between atm_dev_register(), atm_dev_lookup() and atm_dev_deregister(). Fix double spin_unlock() bug. Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl> Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
4969328026
commit
aaaaaadbe7
@@ -427,12 +427,12 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci)
|
||||
dev = try_then_request_module(atm_dev_lookup(itf), "atm-device-%d", itf);
|
||||
} else {
|
||||
dev = NULL;
|
||||
spin_lock(&atm_dev_lock);
|
||||
down(&atm_dev_mutex);
|
||||
if (!list_empty(&atm_devs)) {
|
||||
dev = list_entry(atm_devs.next, struct atm_dev, dev_list);
|
||||
atm_dev_hold(dev);
|
||||
}
|
||||
spin_unlock(&atm_dev_lock);
|
||||
up(&atm_dev_mutex);
|
||||
}
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
|
Reference in New Issue
Block a user