From: Larry Finger <Larry.Finger@lwfinger.net>
To: htl10@users.sourceforge.net,
Herton Ronaldo Krzesinski <herton@canonical.com>,
Kalle Valo <kvalo@codeaurora.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
gregkh@linuxfoundation.org, Salah Triki <salah.triki@gmail.com>
Cc: 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()
Date: Sun, 25 Jul 2021 14:46:57 -0500 [thread overview]
Message-ID: <e761905b-0449-9463-c3ab-923aff36e4df@lwfinger.net> (raw)
In-Reply-To: <53895498.1259278.1627160074135@mail.yahoo.com>
On 7/24/21 3:54 PM, Hin-Tak Leung wrote:
>
>
> On Saturday, 24 July 2021, 19:35:12 BST, Salah Triki <salah.triki@gmail.com> wrote:
>
>
> > Replace udev with usb_get_dev() in order to make code cleaner.
>
> > Signed-off-by: Salah Triki <salah.triki@gmail.com>
> > ---
> > 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?
My belief was that probe routines were called in order, which was confirmed by
GregKH. As a result, there can be no race condition, and the order of setting
the reference count does not matter. On the other hand, the current code is not
misleading, nor unclear. Why should it be changed?
NACK on the patch.
Larry
next prev parent reply other threads:[~2021-07-25 19:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-24 18:34 [PATCH] wireless: rtl8187: replace udev with usb_get_dev() Salah Triki
[not found] ` <53895498.1259278.1627160074135@mail.yahoo.com>
2021-07-25 6:33 ` Greg KH
2021-07-25 19:46 ` Larry Finger [this message]
2021-07-27 6:10 ` Kalle Valo
[not found] <1490129435.403938.1627412276697.ref@mail.yahoo.com>
2021-07-27 18:57 ` Hin-Tak Leung
2021-07-28 7:13 ` 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=e761905b-0449-9463-c3ab-923aff36e4df@lwfinger.net \
--to=larry.finger@lwfinger.net \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=herton@canonical.com \
--cc=htl10@users.sourceforge.net \
--cc=kuba@kernel.org \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=salah.triki@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).