lkml.org 
[lkml]   [2013]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[47/85] dlci: acquire rtnl_lock before calling __dev_get_by_name()
3.2.49-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Zefan Li <lizefan@huawei.com>

commit 11eb2645cbf38a08ae491bf6c602eea900ec0bb5 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: Ben Hutchings <ben@decadent.org.uk>
---
drivers/net/wan/dlci.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -386,20 +386,24 @@ static int dlci_del(struct dlci_add *dlc
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);
@@ -408,8 +412,8 @@ static int dlci_del(struct dlci_add *dlc

dev_put(slave);
}
+out:
rtnl_unlock();
-
return err;
}



\
 
 \ /
  Last update: 2013-07-24 17:21    [W:0.446 / U:20.712 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site