]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net-sysfs: Fix memory leak in XPS configuration
authorAlexander Duyck <alexander.h.duyck@intel.com>
Thu, 31 May 2018 19:59:46 +0000 (15:59 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Jun 2018 03:02:42 +0000 (23:02 -0400)
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>
net/core/net-sysfs.c

index c476f07941323f0b9ff27e947583dc6adc8d728e..bb7e80f4ced3746dc6946cfbc3e71520db503e50 100644 (file)
@@ -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) {
@@ -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) {