From fdb54afb5f66a37c72d8344d1309fdd908eaafbf Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 22 Nov 2012 07:32:46 -0800 Subject: [PATCH] --- yaml --- r: 339352 b: refs/heads/master c: 6d5759dd02af5307e71ca928be11005c08f8f967 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/net/core/netprio_cgroup.c | 56 +++++++-------------------------- 2 files changed, 12 insertions(+), 46 deletions(-) diff --git a/[refs] b/[refs] index 192962057a9d..a7996af62ee5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0ba18f7a5e268e095f79e32b7b47e8ce4fbabbe2 +refs/heads/master: 6d5759dd02af5307e71ca928be11005c08f8f967 diff --git a/trunk/net/core/netprio_cgroup.c b/trunk/net/core/netprio_cgroup.c index f0b6b0d572c1..66d98daf8aef 100644 --- a/trunk/net/core/netprio_cgroup.c +++ b/trunk/net/core/netprio_cgroup.c @@ -176,66 +176,32 @@ static int read_priomap(struct cgroup *cont, struct cftype *cft, static int write_priomap(struct cgroup *cgrp, struct cftype *cft, const char *buffer) { - char *devname = kstrdup(buffer, GFP_KERNEL); - int ret = -EINVAL; u32 prioidx = cgrp_netprio_state(cgrp)->prioidx; - unsigned long priority; - char *priostr; + char devname[IFNAMSIZ + 1]; struct net_device *dev; struct netprio_map *map; + u32 prio; + int ret; - if (!devname) - return -ENOMEM; - - /* - * Minimally sized valid priomap string - */ - if (strlen(devname) < 3) - goto out_free_devname; - - priostr = strstr(devname, " "); - if (!priostr) - goto out_free_devname; - - /* - *Separate the devname from the associated priority - *and advance the priostr pointer to the priority value - */ - *priostr = '\0'; - priostr++; - - /* - * If the priostr points to NULL, we're at the end of the passed - * in string, and its not a valid write - */ - if (*priostr == '\0') - goto out_free_devname; - - ret = kstrtoul(priostr, 10, &priority); - if (ret < 0) - goto out_free_devname; - - ret = -ENODEV; + if (sscanf(buffer, "%"__stringify(IFNAMSIZ)"s %u", devname, &prio) != 2) + return -EINVAL; dev = dev_get_by_name(&init_net, devname); if (!dev) - goto out_free_devname; + return -ENODEV; rtnl_lock(); + ret = write_update_netdev_table(dev); - if (ret < 0) - goto out_put_dev; + if (ret) + goto out_unlock; map = rtnl_dereference(dev->priomap); if (map) - map->priomap[prioidx] = priority; - -out_put_dev: + map->priomap[prioidx] = prio; +out_unlock: rtnl_unlock(); dev_put(dev); - -out_free_devname: - kfree(devname); return ret; }