public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: Fix locking bug in netif_set_xps_queue
@ 2013-02-22 16:38 Alexander Duyck
  2013-02-22 20:14 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Duyck @ 2013-02-22 16:38 UTC (permalink / raw)
  To: netdev; +Cc: fengguang.wu, davem, dan.carpenter, jeffrey.t.kirsher

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>
---
 net/core/dev.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 17bc535..18d8b5a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: Fix locking bug in netif_set_xps_queue
  2013-02-22 16:38 [PATCH] net: Fix locking bug in netif_set_xps_queue Alexander Duyck
@ 2013-02-22 20:14 ` David Miller
  2013-02-22 21:21   ` Alexander Duyck
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2013-02-22 20:14 UTC (permalink / raw)
  To: alexander.h.duyck; +Cc: netdev, fengguang.wu, dan.carpenter, jeffrey.t.kirsher

From: Alexander Duyck <alexander.h.duyck@intel.com>
Date: Fri, 22 Feb 2013 08:38:44 -0800

> 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>

Applied and queue up for -stable, thanks Alex.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: Fix locking bug in netif_set_xps_queue
  2013-02-22 20:14 ` David Miller
@ 2013-02-22 21:21   ` Alexander Duyck
  2013-02-22 21:44     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Duyck @ 2013-02-22 21:21 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, fengguang.wu, dan.carpenter, jeffrey.t.kirsher

On 02/22/2013 12:14 PM, David Miller wrote:
> From: Alexander Duyck <alexander.h.duyck@intel.com>
> Date: Fri, 22 Feb 2013 08:38:44 -0800
>
>> 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>
> Applied and queue up for -stable, thanks Alex.

No patch is needed for -stable.  This was something I had introduced
into net-next when I moved the XPS logic into its own function.

Thanks,

Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: Fix locking bug in netif_set_xps_queue
  2013-02-22 21:21   ` Alexander Duyck
@ 2013-02-22 21:44     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-02-22 21:44 UTC (permalink / raw)
  To: alexander.h.duyck; +Cc: netdev, fengguang.wu, dan.carpenter, jeffrey.t.kirsher

From: Alexander Duyck <alexander.h.duyck@intel.com>
Date: Fri, 22 Feb 2013 13:21:09 -0800

> On 02/22/2013 12:14 PM, David Miller wrote:
>> From: Alexander Duyck <alexander.h.duyck@intel.com>
>> Date: Fri, 22 Feb 2013 08:38:44 -0800
>>
>>> 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>
>> Applied and queue up for -stable, thanks Alex.
> 
> No patch is needed for -stable.  This was something I had introduced
> into net-next when I moved the XPS logic into its own function.

Great, thanks for letting me know.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-22 21:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-22 16:38 [PATCH] net: Fix locking bug in netif_set_xps_queue Alexander Duyck
2013-02-22 20:14 ` David Miller
2013-02-22 21:21   ` Alexander Duyck
2013-02-22 21:44     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox