Skip to content

Commit 664088f

Browse files
Alexander Duyckdavem330
authored andcommitted
net-sysfs: Fix memory leak in XPS configuration
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 16e6653 commit 664088f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/core/net-sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,9 +1214,6 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue,
12141214
cpumask_var_t mask;
12151215
unsigned long index;
12161216

1217-
if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
1218-
return -ENOMEM;
1219-
12201217
index = get_netdev_queue_index(queue);
12211218

12221219
if (dev->num_tc) {
@@ -1226,6 +1223,9 @@ static ssize_t xps_cpus_show(struct netdev_queue *queue,
12261223
return -EINVAL;
12271224
}
12281225

1226+
if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
1227+
return -ENOMEM;
1228+
12291229
rcu_read_lock();
12301230
dev_maps = rcu_dereference(dev->xps_maps);
12311231
if (dev_maps) {

0 commit comments

Comments
 (0)