netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libertas: Add spinlock to avoid race condition
@ 2016-06-15 11:34 Pavel Andrianov
  2016-06-15 13:01 ` Vaishali Thakkar
  2016-06-29 15:47 ` Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Pavel Andrianov @ 2016-06-15 11:34 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Pavel Andrianov, libertas-dev, linux-wireless, netdev,
	linux-kernel, ldv-project, vaishali.thakkar

lbs_mac_event_disconnected may free priv->currenttxskb
while lbs_hard_start_xmit accesses to it.
The patch adds a spinlock for mutual exclusion.

Tested on OLPC XO-1 (usb8388) and XO-1.5 (sd8686) with v4.7-rc3.

Confirmed that lbs_mac_event_disconnected is being called on the
station when hostapd on access point is given SIGHUP.

Signed-off-by: Pavel <andrianov@ispras.ru>
Tested-by: James Cameron <quozl@laptop.org>
---
 drivers/net/wireless/marvell/libertas/cmdresp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/marvell/libertas/cmdresp.c b/drivers/net/wireless/marvell/libertas/cmdresp.c
index c95bf6d..c67ae07 100644
--- a/drivers/net/wireless/marvell/libertas/cmdresp.c
+++ b/drivers/net/wireless/marvell/libertas/cmdresp.c
@@ -27,6 +27,8 @@
 void lbs_mac_event_disconnected(struct lbs_private *priv,
 				bool locally_generated)
 {
+	unsigned long flags;
+
 	if (priv->connect_status != LBS_CONNECTED)
 		return;
 
@@ -46,9 +48,11 @@ void lbs_mac_event_disconnected(struct lbs_private *priv,
 	netif_carrier_off(priv->dev);
 
 	/* Free Tx and Rx packets */
+	spin_lock_irqsave(&priv->driver_lock, flags);
 	kfree_skb(priv->currenttxskb);
 	priv->currenttxskb = NULL;
 	priv->tx_pending_len = 0;
+	spin_unlock_irqrestore(&priv->driver_lock, flags);
 
 	priv->connect_status = LBS_DISCONNECTED;
 
-- 
1.7.11.7

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

* Re: [PATCH] libertas: Add spinlock to avoid race condition
  2016-06-15 11:34 [PATCH] libertas: Add spinlock to avoid race condition Pavel Andrianov
@ 2016-06-15 13:01 ` Vaishali Thakkar
  2016-06-29 15:47 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Vaishali Thakkar @ 2016-06-15 13:01 UTC (permalink / raw)
  To: Pavel Andrianov, Kalle Valo
  Cc: libertas-dev, linux-wireless, netdev, linux-kernel, ldv-project



On Wednesday 15 June 2016 05:04 PM, Pavel Andrianov wrote:
> lbs_mac_event_disconnected may free priv->currenttxskb
> while lbs_hard_start_xmit accesses to it.
> The patch adds a spinlock for mutual exclusion.
> 
> Tested on OLPC XO-1 (usb8388) and XO-1.5 (sd8686) with v4.7-rc3.
> 
> Confirmed that lbs_mac_event_disconnected is being called on the
> station when hostapd on access point is given SIGHUP.
> 
> Signed-off-by: Pavel <andrianov@ispras.ru>
> Tested-by: James Cameron <quozl@laptop.org>

Looks good to me.

Acked-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>

> ---
>  drivers/net/wireless/marvell/libertas/cmdresp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/wireless/marvell/libertas/cmdresp.c b/drivers/net/wireless/marvell/libertas/cmdresp.c
> index c95bf6d..c67ae07 100644
> --- a/drivers/net/wireless/marvell/libertas/cmdresp.c
> +++ b/drivers/net/wireless/marvell/libertas/cmdresp.c
> @@ -27,6 +27,8 @@
>  void lbs_mac_event_disconnected(struct lbs_private *priv,
>  				bool locally_generated)
>  {
> +	unsigned long flags;
> +
>  	if (priv->connect_status != LBS_CONNECTED)
>  		return;
>  
> @@ -46,9 +48,11 @@ void lbs_mac_event_disconnected(struct lbs_private *priv,
>  	netif_carrier_off(priv->dev);
>  
>  	/* Free Tx and Rx packets */
> +	spin_lock_irqsave(&priv->driver_lock, flags);
>  	kfree_skb(priv->currenttxskb);
>  	priv->currenttxskb = NULL;
>  	priv->tx_pending_len = 0;
> +	spin_unlock_irqrestore(&priv->driver_lock, flags);
>  
>  	priv->connect_status = LBS_DISCONNECTED;
>  
> 

-- 
Vaishali

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

* Re: libertas: Add spinlock to avoid race condition
  2016-06-15 11:34 [PATCH] libertas: Add spinlock to avoid race condition Pavel Andrianov
  2016-06-15 13:01 ` Vaishali Thakkar
@ 2016-06-29 15:47 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2016-06-29 15:47 UTC (permalink / raw)
  To: Pavel Andrianov
  Cc: Pavel Andrianov, libertas-dev, linux-wireless, netdev,
	linux-kernel, ldv-project, vaishali.thakkar

Pavel Andrianov <andrianov@ispras.ru> wrote:
> lbs_mac_event_disconnected may free priv->currenttxskb
> while lbs_hard_start_xmit accesses to it.
> The patch adds a spinlock for mutual exclusion.
> 
> Tested on OLPC XO-1 (usb8388) and XO-1.5 (sd8686) with v4.7-rc3.
> 
> Confirmed that lbs_mac_event_disconnected is being called on the
> station when hostapd on access point is given SIGHUP.
> 
> Signed-off-by: Pavel <andrianov@ispras.ru>
> Tested-by: James Cameron <quozl@laptop.org>
> Acked-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>

Thanks, 1 patch applied to wireless-drivers-next.git:

f52b041aed77 libertas: Add spinlock to avoid race condition

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9178477/

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

end of thread, other threads:[~2016-06-29 15:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-15 11:34 [PATCH] libertas: Add spinlock to avoid race condition Pavel Andrianov
2016-06-15 13:01 ` Vaishali Thakkar
2016-06-29 15:47 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).