Skip to content

Commit

Permalink
net-sysfs: Fix memory leak in XPS configuration
Browse files Browse the repository at this point in the history
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: 184c449 ("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>
  • Loading branch information
Alexander Duyck authored and davem330 committed Jun 1, 2018
1 parent 16e6653 commit 664088f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,9 +1214,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) {
Expand All @@ -1226,6 +1223,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) {
Expand Down

0 comments on commit 664088f

Please sign in to comment.