From: Justin Pettit Date: Tue, 13 Apr 2010 22:53:37 +0000 (-0700) Subject: veth: Fix problems removing veth devices X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b9334be31c1992ddb6e14e8aea6413f00ddb1ab;p=openvswitch 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. --- 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)