Commit 0dbd822f authored by Alexander Duyck's avatar Alexander Duyck Committed by Greg Kroah-Hartman

net-sysfs: Fix memory leak in XPS configuration

[ Upstream commit 664088f8 ]

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: 184c449f ("net: Add support for XPS with QoS via traffic classes")
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 90067998
...@@ -1207,9 +1207,6 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue, ...@@ -1207,9 +1207,6 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue,
cpumask_var_t mask; cpumask_var_t mask;
unsigned long index; unsigned long index;
if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
return -ENOMEM;
index = get_netdev_queue_index(queue); index = get_netdev_queue_index(queue);
if (dev->num_tc) { if (dev->num_tc) {
...@@ -1219,6 +1216,9 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue, ...@@ -1219,6 +1216,9 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue,
return -EINVAL; return -EINVAL;
} }
if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
return -ENOMEM;
rcu_read_lock(); rcu_read_lock();
dev_maps = rcu_dereference(dev->xps_maps); dev_maps = rcu_dereference(dev->xps_maps);
if (dev_maps) { if (dev_maps) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment