All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vaishali Thakkar <vaishali.thakkar@oracle.com>
To: Pavel Andrianov <andrianov@ispras.ru>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Kalle Valo <kvalo@codeaurora.org>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org
Subject: Re: [PATCH] wl3501_cs: Add spinlock to wl3501_reset
Date: Thu, 4 Aug 2016 10:31:41 +0530	[thread overview]
Message-ID: <57A2CC35.60808@oracle.com> (raw)
In-Reply-To: <1470130913-5218-1-git-send-email-andrianov@ispras.ru>



On Tuesday 02 August 2016 03:11 PM, Pavel Andrianov wrote:
> Likely wl3501_reset should acquire spinlock as wl3501_{open, close}.
> One of calls of wl3501_reset has been already protected.
> The others were unprotected and might lead to a race condition.
> The patch adds spinlock into the wl3501_reset and removes it from 
> wl3501_tx_timeout.
> 
> Found by Linux Driver Verification project (linuxtesting.org)
> 
> Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>

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

> ---
>  drivers/net/wireless/wl3501_cs.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
> index 13fd734..196f13c 100644
> --- a/drivers/net/wireless/wl3501_cs.c
> +++ b/drivers/net/wireless/wl3501_cs.c
> @@ -1247,7 +1247,9 @@ static int wl3501_reset(struct net_device *dev)
>  {
>  	struct wl3501_card *this = netdev_priv(dev);
>  	int rc = -ENODEV;
> +	unsigned long flags;
>  
> +	spin_lock_irqsave(&this->lock, flags);
>  	wl3501_block_interrupt(this);
>  
>  	if (wl3501_init_firmware(this)) {
> @@ -1269,20 +1271,17 @@ static int wl3501_reset(struct net_device *dev)
>  	pr_debug("%s: device reset", dev->name);
>  	rc = 0;
>  out:
> +	spin_unlock_irqrestore(&this->lock, flags);
>  	return rc;
>  }
>  
>  static void wl3501_tx_timeout(struct net_device *dev)
>  {
> -	struct wl3501_card *this = netdev_priv(dev);
>  	struct net_device_stats *stats = &dev->stats;
> -	unsigned long flags;
>  	int rc;
>  
>  	stats->tx_errors++;
> -	spin_lock_irqsave(&this->lock, flags);
>  	rc = wl3501_reset(dev);
> -	spin_unlock_irqrestore(&this->lock, flags);
>  	if (rc)
>  		printk(KERN_ERR "%s: Error %d resetting card on Tx timeout!\n",
>  		       dev->name, rc);
> 

-- 
Vaishali

WARNING: multiple messages have this Message-ID (diff)
From: Vaishali Thakkar <vaishali.thakkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Pavel Andrianov
	<andrianov-ufN2psIa012HXe+LvDLADg@public.gmane.org>,
	Arnaldo Carvalho de Melo
	<acme-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	ldv-project-tpLiQldItUH5n4uC9ZG1Ww@public.gmane.org
Subject: Re: [PATCH] wl3501_cs: Add spinlock to wl3501_reset
Date: Thu, 4 Aug 2016 10:31:41 +0530	[thread overview]
Message-ID: <57A2CC35.60808@oracle.com> (raw)
In-Reply-To: <1470130913-5218-1-git-send-email-andrianov-ufN2psIa012HXe+LvDLADg@public.gmane.org>



On Tuesday 02 August 2016 03:11 PM, Pavel Andrianov wrote:
> Likely wl3501_reset should acquire spinlock as wl3501_{open, close}.
> One of calls of wl3501_reset has been already protected.
> The others were unprotected and might lead to a race condition.
> The patch adds spinlock into the wl3501_reset and removes it from 
> wl3501_tx_timeout.
> 
> Found by Linux Driver Verification project (linuxtesting.org)
> 
> Signed-off-by: Pavel Andrianov <andrianov-ufN2psIa012HXe+LvDLADg@public.gmane.org>

Acked-by: Vaishali Thakkar <vaishali.thakkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

> ---
>  drivers/net/wireless/wl3501_cs.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
> index 13fd734..196f13c 100644
> --- a/drivers/net/wireless/wl3501_cs.c
> +++ b/drivers/net/wireless/wl3501_cs.c
> @@ -1247,7 +1247,9 @@ static int wl3501_reset(struct net_device *dev)
>  {
>  	struct wl3501_card *this = netdev_priv(dev);
>  	int rc = -ENODEV;
> +	unsigned long flags;
>  
> +	spin_lock_irqsave(&this->lock, flags);
>  	wl3501_block_interrupt(this);
>  
>  	if (wl3501_init_firmware(this)) {
> @@ -1269,20 +1271,17 @@ static int wl3501_reset(struct net_device *dev)
>  	pr_debug("%s: device reset", dev->name);
>  	rc = 0;
>  out:
> +	spin_unlock_irqrestore(&this->lock, flags);
>  	return rc;
>  }
>  
>  static void wl3501_tx_timeout(struct net_device *dev)
>  {
> -	struct wl3501_card *this = netdev_priv(dev);
>  	struct net_device_stats *stats = &dev->stats;
> -	unsigned long flags;
>  	int rc;
>  
>  	stats->tx_errors++;
> -	spin_lock_irqsave(&this->lock, flags);
>  	rc = wl3501_reset(dev);
> -	spin_unlock_irqrestore(&this->lock, flags);
>  	if (rc)
>  		printk(KERN_ERR "%s: Error %d resetting card on Tx timeout!\n",
>  		       dev->name, rc);
> 

-- 
Vaishali
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-08-04  5:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02  9:41 [PATCH] wl3501_cs: Add spinlock to wl3501_reset Pavel Andrianov
2016-08-04  5:01 ` Vaishali Thakkar [this message]
2016-08-04  5:01   ` Vaishali Thakkar
2016-09-03 10:01 ` Kalle Valo
2016-09-03 10:01   ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57A2CC35.60808@oracle.com \
    --to=vaishali.thakkar@oracle.com \
    --cc=acme@redhat.com \
    --cc=andrianov@ispras.ru \
    --cc=kvalo@codeaurora.org \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.