Skip to content

Commit

Permalink
dlci: acquire rtnl_lock before calling __dev_get_by_name()
Browse files Browse the repository at this point in the history
commit 11eb264 upstream.

Otherwise the net device returned can be freed at anytime.

Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
lizf-os authored and gregkh committed Jul 3, 2013
1 parent e2652ea commit 72ad35b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/net/wan/dlci.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,24 @@ static int dlci_del(struct dlci_add *dlci)
struct net_device *master, *slave;
int err;

rtnl_lock();

/* validate slave device */
master = __dev_get_by_name(&init_net, dlci->devname);
if (!master)
return -ENODEV;
if (!master) {
err = -ENODEV;
goto out;
}

if (netif_running(master)) {
return -EBUSY;
err = -EBUSY;
goto out;
}

dlp = netdev_priv(master);
slave = dlp->slave;
flp = netdev_priv(slave);

rtnl_lock();
err = (*flp->deassoc)(slave, master);
if (!err) {
list_del(&dlp->list);
Expand All @@ -400,8 +404,8 @@ static int dlci_del(struct dlci_add *dlci)

dev_put(slave);
}
out:
rtnl_unlock();

return err;
}

Expand Down

0 comments on commit 72ad35b

Please sign in to comment.