From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38565C7EE24 for ; Sat, 6 May 2023 05:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjEFFvJ (ORCPT ); Sat, 6 May 2023 01:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjEFFvG (ORCPT ); Sat, 6 May 2023 01:51:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 404F57DA5 for ; Fri, 5 May 2023 22:51:06 -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 D1681608D3 for ; Sat, 6 May 2023 05:51:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C36DC433EF; Sat, 6 May 2023 05:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683352265; bh=cJNlq7s4/qMCZuG3GeMtE0cdpmLxxkHIwVlStqs9/+w=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=EO5Un2rUn02SD6ouy0+UQ2GFDcQmNhBaxbZ/RAg4XRgOw6B1kSVjHH70U6uXKaVrI z9GDJsy4nWPuQuZtA3ms+X1AUE8jvNGIVgCxWLl42sya4mFwYzC6srLnbT74D5b4UQ MKpl1Lo7/Fvqv++1Mwdv3ORGT8v8Imj79sIJQm54mbfibxyfEeL9YRXUneARO3Q9vb 5z5qLYDfaP2+assuh6k7n9Nkrd6BPcik7OYEbWmh2gTmqk3bPeLYqpdLrsdHdPzkSq 012q2aoj2+5X1lwZ3T90XIvcRhXaHfedoB6eq8woWXGjs3HzkfdHm++KcuBkEjN2j9 YaChhh+Jlk+kA== From: Kalle Valo To: Cc: , , , Subject: Re: [PATCH] wifi: wilc1000: fix kernel oops during interface down during background scan References: <20230404012010.15261-1-ajay.kathat@microchip.com> <87wn1mok5g.fsf@kernel.org> Date: Sat, 06 May 2023 08:50:58 +0300 In-Reply-To: (Ajay Kathat's message of "Fri, 5 May 2023 20:53:12 +0000") Message-ID: <87sfcanh31.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org writes: >>> @@ -781,13 +776,15 @@ static int wilc_mac_close(struct net_device *ndev) >>> if (vif->ndev) { >>> netif_stop_queue(vif->ndev); >>> >>> + if (wl->open_ifcs == 0) >>> + wl->close = 1; >>> + >> >> wl-close is an int, I wonder if it's racy to int as a flag like this? In >> cases like this I usually use set_bit() & co because those guarantee >> atomicity, though don't know if that's overkill. >> > > I think it's a good idea to use an atomic operation but I am not sure if > using atomic for 'wl->close' will have much impact. For instance, if any > new work gets added to the workqueue before the 'wl->close=1' is fully > completed, then that work would get executed as normal. Sure, this is most likely a small race condition. But still a race. > However, I feel it's safe to define 'wl->close' as atomic_t type. I will > prepare the conversion patch and will try to include it along with the > updated version of this patch. Why atomic_t? You only use values 0 and 1 so test_bit() and set_bit() sounds more approriate to me. -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches