Skip to content

Commit

Permalink
net: Fix locking bug in netif_set_xps_queue
Browse files Browse the repository at this point in the history
Smatch found a locking bug in netif_set_xps_queue in which we were not
releasing the lock in the case of an allocation failure.

This change corrects that so that we release the xps_map_mutex before
returning -ENOMEM in the case of an allocation failure.

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 David S. Miller committed Feb 22, 2013
1 parent 5b05204 commit 2bb60cb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1882,8 +1882,10 @@ int netif_set_xps_queue(struct net_device *dev, struct cpumask *mask, u16 index)

if (!new_dev_maps)
new_dev_maps = kzalloc(maps_sz, GFP_KERNEL);
if (!new_dev_maps)
if (!new_dev_maps) {
mutex_unlock(&xps_map_mutex);
return -ENOMEM;
}

map = dev_maps ? xmap_dereference(dev_maps->cpu_map[cpu]) :
NULL;
Expand Down

0 comments on commit 2bb60cb

Please sign in to comment.