Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1865146rwr; Fri, 5 May 2023 23:57:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Fbf2UTAefpYtISTxfM3sXlnrlx/v2cbyiWQ6toATxXi7UmRF5Bdu0MxNhUXJkssElzUjQ X-Received: by 2002:a05:6a20:3c8e:b0:f2:93b7:a452 with SMTP id b14-20020a056a203c8e00b000f293b7a452mr4832094pzj.4.1683356276564; Fri, 05 May 2023 23:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683356276; cv=none; d=google.com; s=arc-20160816; b=C1rZZBbFb5uM2+wt1jKscG/nH3WRR+Ob2RvEfRyBdmSldchE1GwLMBhx8tvnfs1i0V jI6q/ea3AuE6eom0vdbYTfBwGo8aCksSKHoVmCn4aNeKd7J1z8ffMC2oIlUUeMpi7zz9 l7ms/Myar3RGUEuAjg5hXzBcxTW9Dt2s69vOuGX/nwT8ndJo754ce/iSg6qu6Y1WUAEl 7QIQjirZhdNoU4Eo1FafJqP1wbcJe35jsdjew3HC9Khuya14xLze1Q6tJM+4+6fE/UD6 YGCJA44cAeQMVYa+OzFixP+vBidAkxpcv46as+mx0v0589PJ0K37yaHaNJvjABR2nPol ODIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DABmJwSZtxYW7NKcqEn74o5eQMUkL1pOC+fd/0hA3qY=; b=b2PuRqmqt7jaidf24QtQONoW1QY+OUKH5zNVlHYdIAs+6xCRdSm1T1F3oeSKWJRQf7 lNDXyJzk0uNJylHAZDImOaHaBIEfikBecuHqmjL+e9Vwnq+uFvynks6lzCL0VR3azMVs C0fUjsBjLILXVNORFgYO/BdYVyP5lDO4p450xSUNf88wKqc634hhUb6vHiQ9BDmzwhRb Bko5J1ZdrvwKtSdfNcvga9HCZBcKTPqrOFVXO1+1Qn6cvk5tbeTPcsoomXArAZOCjfNP 8BVhgmwn+F5Y6Szg4jQsM/rQgZYRZokgm2ZjgRdJzxOp0GEqG573F4R2CiFO5gOS8K0P gMsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ADHvX3Jm; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u62-20020a638541000000b00520e69b7439si3933965pgd.560.2023.05.05.23.57.43; Fri, 05 May 2023 23:57:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ADHvX3Jm; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbjEFG5l (ORCPT + 61 others); Sat, 6 May 2023 02:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjEFG5k (ORCPT ); Sat, 6 May 2023 02:57:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA4F52727; Fri, 5 May 2023 23:57:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6F04B60E9D; Sat, 6 May 2023 06:57:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D08A3C433D2; Sat, 6 May 2023 06:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1683356257; bh=SKrqn2Kf7IyTjWUu3zTHQ7N8L6W4rk8BWQ+SFkk8n6A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ADHvX3JmL0/4Z3Mml7MQfpkM8jJn8SBHsMF7qDZ2i96Z+u1zFFLapvNtXDAzqOmVT olavraTQxrjMbgFyLogJWNpThKd8EsMKWQoeqiEjHDnVCbUW3516FRDH6K9rj2dKng ekHIPhrSxqrjXY7EEaFN6AN3OXd/OgX81DBtbNgQ= Date: Sat, 6 May 2023 14:52:25 +0900 From: Greg KH 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 Message-ID: <2023050645-vaguely-unruffled-fd81@gregkh> References: <20230505232902.22651-1-ajay.kathat@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230505232902.22651-1-ajay.kathat@microchip.com> X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 > Link: https://lore.kernel.org/linux-wireless/20221024135407.7udo3dwl3mqyv2yj@0002.3ffe.de/ > Signed-off-by: Ajay Singh > --- > 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