From 5b9334be31c1992ddb6e14e8aea6413f00ddb1ab Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Tue, 13 Apr 2010 15:53:37 -0700 Subject: [PATCH] veth: Fix problems removing veth devices When a user tried to delete a veth device through sysfs, the driver wasn't properly parsing the device name. Also, it called dev_get_by_name(), which increments a refcount on the device, but didn't make a dev_put() before trying to delete it. --- datapath/linux-2.6/compat-2.6/veth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/datapath/linux-2.6/compat-2.6/veth.c b/datapath/linux-2.6/compat-2.6/veth.c index e609c627..66aae0b9 100644 --- a/datapath/linux-2.6/compat-2.6/veth.c +++ b/datapath/linux-2.6/compat-2.6/veth.c @@ -454,10 +454,13 @@ static ssize_t veth_store_veth_pairs(struct class *cls, const char *buffer, rtnl_unlock(); return retval ? retval : count; } else if (c == '-') { + char devname[IFNAMSIZ + 1] = ""; struct net_device *dev; + strncat(devname, buffer, + min_t(int, sizeof devname, strcspn(buffer, "\n"))); rtnl_lock(); - dev = dev_get_by_name(buffer); + dev = __dev_get_by_name(devname); if (!dev) retval = -ENODEV; else if (dev->init != veth_dev_init) -- 2.30.2