public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Ajay.Kathat@microchip.com
Cc: linux-wireless@vger.kernel.org, Claudiu.Beznea@microchip.com,
	Sripad.Balwadgi@microchip.com, stable@vger.kernel.org,
	mwalle@kernel.org
Subject: Re: [PATCH v2] wifi: wilc1000: fix kernel oops during interface down during background scan
Date: Sat, 6 May 2023 14:52:25 +0900	[thread overview]
Message-ID: <2023050645-vaguely-unruffled-fd81@gregkh> (raw)
In-Reply-To: <20230505232902.22651-1-ajay.kathat@microchip.com>

On Fri, May 05, 2023 at 11:42:51PM +0000, Ajay.Kathat@microchip.com wrote:
> Fix for kernel crash observed with following test procedure:
>   while true;
>     do ifconfig wlan0 up;
>     iw dev wlan0 scan &
>     ifconfig wlan0 down;
>   done
> 
> During the above test procedure, the scan results are received from firmware
> for 'iw scan' command gets queued even when the interface is going down. It
> was causing the kernel oops when dereferencing the freed pointers.
> 
> For synchronization, 'mac_close()' calls flush_workqueue() to block its
> execution till all pending work is completed. Afterwards 'wilc->close' flag
> which is set before the flush_workqueue() should avoid adding new work.
> Added 'wilc->close' check in wilc_handle_isr() which is common for
> SPI/SDIO bus to ignore the interrupts from firmware that inturns adds the
> work since the interface is getting closed.
> 
> Also, removed isr_uh_routine() as it's not necessary after 'wl->close' check
> is added in wilc_handle_isr(). So now the default primary handler would be
> used for threaded IRQ.
> 
> Cc: stable@vger.kernel.org
> Reported-by: Michael Walle <mwalle@kernel.org>
> Link: https://lore.kernel.org/linux-wireless/20221024135407.7udo3dwl3mqyv2yj@0002.3ffe.de/
> Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
> ---
>  changes since v1:
>   - updated commit description and included 'Link:' tag
>   - use atomic_t type for 'close' variable
>   - set close state after clearing ongoing scan operation
>   - make use of default primary handler for threaded_irq
>   - avoid false failure debug message during mac_close
> 
>  .../wireless/microchip/wilc1000/cfg80211.c    |  2 +-
>  drivers/net/wireless/microchip/wilc1000/hif.c |  2 +-
>  .../net/wireless/microchip/wilc1000/netdev.c  | 33 ++++++-------------
>  .../net/wireless/microchip/wilc1000/netdev.h  |  2 +-
>  .../net/wireless/microchip/wilc1000/wlan.c    |  3 ++
>  5 files changed, 16 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
> index b545d93c6e37..a90a75094486 100644
> --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c
> +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
> @@ -461,7 +461,7 @@ static int disconnect(struct wiphy *wiphy, struct net_device *dev,
>  	if (!wilc)
>  		return -EIO;
> 
> -	if (wilc->close) {
> +	if (atomic_read(&wilc->close)) {

What happens if this changes right after you read from this?

Don't reimplement locks on your own, use a real one please.

thanks,

greg k-h

  reply	other threads:[~2023-05-06  6:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 23:42 [PATCH v2] wifi: wilc1000: fix kernel oops during interface down during background scan Ajay.Kathat
2023-05-06  5:52 ` Greg KH [this message]
2023-05-09 23:56   ` Ajay.Kathat
2023-05-06  5:57 ` 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=2023050645-vaguely-unruffled-fd81@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Ajay.Kathat@microchip.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=Sripad.Balwadgi@microchip.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mwalle@kernel.org \
    --cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox