Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2604897pxv; Sat, 24 Jul 2021 23:35:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlfcNf4p6SiGFuMTnclI/GtuFh7EtgBsCCXXBT69xDuGyHlRm/rzE38QLKxeVqQ+56YgiH X-Received: by 2002:a92:d251:: with SMTP id v17mr8517584ilg.283.1627194917608; Sat, 24 Jul 2021 23:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627194917; cv=none; d=google.com; s=arc-20160816; b=wdcrduqmZwt2A/7Idh/orTkw3W8eS52gBGvOMOgwHplqR+mtkwT4uVVTW2iBnfn048 yRuoGr3qae5DEzBYDoBwxO1E0vOAGW4yRxNA9B+xy6QDYHTkORAH9jUY03Z78V+avoLG 4JFfXLidUB0yqYjok49ak+Gr0kQXkvVKynmsp1mK1Ac4YRIZL+NY1+ilUvMl6pAO2bTC efTUQA68icXQ6ahExXfskX15NzAk60SxRXmiOeHDVEdwFX2jGpk35gKm5T2dRhUnQKtU 9Jc7wIyYWkk8sS1ZKlzemzp/2wKDaad8TQp/TefmcYJc/CUjjqTWWz1HVqzGkybe/sG6 5XYw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hC36u6uALEkoM0DDOugustw4ZvJiXPdJs8Q7yJqUxqg=; b=XmkMvbnBe/xSvsMrIea4EZio4zshgs3gPe7WHM/u7y9vbBP5TTLJCslc0ExdJnO54V wv8EiU6k7XfAaQ7oD4eOn+oXT/UcoyjdX3eOD/eUGUoYCyUQUWIMm4PN+S+CTBS9CgQX HB4SRP5Gdbt+5FAbprqZ2gBJwC1zc5tNHqf4OBbVJpro1HjdkBeWZo6vSgxrHdSxPHsQ myx0+FBL3c888GyYVdS6tQ78R+MCUBv11n1GTNo8C5d48MQRjbbCm2JDzBJG6DRgoFR6 /yyaB1bHTrRvpa7kIgO5F+f77atdW5PxYe/zZHNkIEp1VOmrUQpeMrVSHChAz6RFZ4ru yLzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lmT3R1Og; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si2929162ilq.105.2021.07.24.23.35.06; Sat, 24 Jul 2021 23:35:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lmT3R1Og; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S230217AbhGYFwe (ORCPT + 99 others); Sun, 25 Jul 2021 01:52:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:43510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbhGYFwe (ORCPT ); Sun, 25 Jul 2021 01:52:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1501760F13; Sun, 25 Jul 2021 06:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627194784; bh=wlXW6USsZex8XdiwmwtjzhgxjC6oifv3Uj+wH6B39gM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lmT3R1OgC+HAe1MwvwkIeU+qo8cAgYd34TMKQfMqAngmhTXkemgZvp9jthyRHAYdW goc+oAwqSYX3M5VX66MGJzFzocozaH6KO/0dBJ7/2rjefSU3adu+Vm3Wo0VY641aCI I6CYsDKQ3UQBvxMpgqGTb0RDyncXKcwXZPbNJJnk= Date: Sun, 25 Jul 2021 08:33:01 +0200 From: Greg KH To: Hin-Tak Leung Cc: Herton Ronaldo Krzesinski , Larry Finger , Kalle Valo , "David S. Miller" , Jakub Kicinski , 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() Message-ID: References: <20210724183457.GA470005@pc> <53895498.1259278.1627160074135@mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <53895498.1259278.1627160074135@mail.yahoo.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 24, 2021 at 08:54:34PM +0000, Hin-Tak Leung wrote: > > > 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. Probe functions are called in order, this should not be an issue. This patch changes nothing, I do not think it is needed at all. thanks, greg k-h