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 X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F2BEC4338F for ; Tue, 27 Jul 2021 06:11:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E694660560 for ; Tue, 27 Jul 2021 06:10:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235609AbhG0GKw (ORCPT ); Tue, 27 Jul 2021 02:10:52 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:51424 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235063AbhG0GKu (ORCPT ); Tue, 27 Jul 2021 02:10:50 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1627366251; h=Content-Type: MIME-Version: Message-ID: In-Reply-To: Date: References: Subject: Cc: To: From: Sender; bh=mGArwDTjXra5T2pzBW7Oz+IaFD5IRPeuL9dvd7Qx/g4=; b=dW2U417UhGzYgztTHAC+tTgbAxZH6EH+ayLcnC+J1ydFPxP8gp8HZDcKxrABf8Z77Fu1IE3R 50RhjRMSwtvtZZLuBCPf40Knm5p9O5K41GGe3QFds+1OZOfUOcTSZuQo1L9lkOYGl2wx7SzP sROsUXwgam96Iwy6NwA17zkPl1o= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-west-2.postgun.com with SMTP id 60ffa36a9771b05b248831e4 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 27 Jul 2021 06:10:50 GMT Sender: kvalo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7B1A5C433F1; Tue, 27 Jul 2021 06:10:50 +0000 (UTC) Received: from tykki (tynnyri.adurom.net [51.15.11.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id 55400C433F1; Tue, 27 Jul 2021 06:10:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 55400C433F1 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Hin-Tak Leung Cc: Herton Ronaldo Krzesinski , Larry Finger , "David S. Miller" , Jakub Kicinski , gregkh@linuxfoundation.org, Salah Triki , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] wireless: rtl8187: replace udev with usb_get_dev() References: <20210724183457.GA470005@pc> <53895498.1259278.1627160074135@mail.yahoo.com> Date: Tue, 27 Jul 2021 09:10:45 +0300 In-Reply-To: <53895498.1259278.1627160074135@mail.yahoo.com> (Hin-Tak Leung's message of "Sat, 24 Jul 2021 20:54:34 +0000 (UTC)") Message-ID: <87im0wguca.fsf@codeaurora.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 Hin-Tak Leung writes: > On Saturday, 24 July 2021, 19:35:12 BST, Salah Triki wrote: > >> Replace udev with usb_get_dev() in order to make code cleaner. > >> Signed-off-by: Salah Triki >> --- >> drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) > >> diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c > b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c >> index eb68b2d3caa1..30bb3c2b8407 100644 >> --- a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c >> +++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c >> @@ -1455,9 +1455,7 @@ static int rtl8187_probe(struct usb_interface *intf, > >> SET_IEEE80211_DEV(dev, &intf->dev); >> usb_set_intfdata(intf, dev); >> - priv->udev = udev; >> - >> - usb_get_dev(udev); >> + priv->udev = usb_get_dev(udev); > >> skb_queue_head_init(&priv->rx_queue); > >> -- >> 2.25.1 > > It is not cleaner - the change is not functionally equivalent. Before > the change, the reference count is increased after the assignment; and > after the change, before the assignment. So my question is, does the > reference count increasing a little earlier matters? What can go wrong > between very short time where the reference count increases, and > priv->udev not yet assigned? I think there might be a race condition > where the probbe function is called very shortly twice. Especially if > the time of running the reference count function is non-trivial. > > Larry, what do you think? BTW, please don't use HTML in emails. Our lists drop all HTML mail (and for a good reason). -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches