History

dlci: acquire rtnl_lock before calling __dev_get_by_name()

Otherwise the net device returned can be freed at anytime.

Zefan Li committed 13 years ago

Commit 11eb2641 parent a5cc68f1 file · +9 −5Browse files

Unified · Split

drivers/net/wan/dlci.c+9−5
@@ -385,20 +385,24 @@ static int dlci_del(struct dlci_add *dlci) · 384 unmodified lines
385385 struct net_device *master, *slave;
386386 int err;
387387
388+ rtnl_lock();
389+
388390 /* validate slave device */
389391 master = __dev_get_by_name(&init_net, dlci->devname);
390− if (!master)
391− return -ENODEV;
392+ if (!master) {
393+ err = -ENODEV;
394+ goto out;
395+ }
392396
393397 if (netif_running(master)) {
394− return -EBUSY;
398+ err = -EBUSY;
399+ goto out;
395400 }
396401
397402 dlp = netdev_priv(master);
398403 slave = dlp->slave;
399404 flp = netdev_priv(slave);
400405
401− rtnl_lock();
402406 err = (*flp->deassoc)(slave, master);
403407 if (!err) {
404408 list_del(&dlp->list);
@@ -407,8 +411,8 @@ static int dlci_del(struct dlci_add *dlci) · 2 unmodified lines
407411
408412 dev_put(slave);
409413 }
414+out:
410415 rtnl_unlock();
411−
412416 return err;
413417 }
414418

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t