diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2018-05-31 15:59:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-06-11 22:49:21 +0200 |
commit | 0dbd822f64401cbdef40e9e476e89f67c690be64 (patch) | |
tree | e1fa80f3d56104267c8e3e5263971ac9e9b45d4c /net/core | |
parent | 900679988fdf24d687c746e909b10e47e442ad05 (diff) |
net-sysfs: Fix memory leak in XPS configuration
[ Upstream commit 664088f8d68178809b848ca450f2797efb34e8e7 ]
This patch reorders the error cases in showing the XPS configuration so
that we hold off on memory allocation until after we have verified that we
can support XPS on a given ring.
Fixes: 184c449f91fe ("net: Add support for XPS with QoS via traffic classes")
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/net-sysfs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 927a6dcbad96..8f17724a173c 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1207,9 +1207,6 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue, cpumask_var_t mask; unsigned long index; - if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) - return -ENOMEM; - index = get_netdev_queue_index(queue); if (dev->num_tc) { @@ -1219,6 +1216,9 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue, return -EINVAL; } + if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) + return -ENOMEM; + rcu_read_lock(); dev_maps = rcu_dereference(dev->xps_maps); if (dev_maps) { |