linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] wireless: rtl8187: replace udev with usb_get_dev()
       [not found] <1490129435.403938.1627412276697.ref@mail.yahoo.com>
@ 2021-07-27 18:57 ` Hin-Tak Leung
  2021-07-28  7:13   ` Kalle Valo
  0 siblings, 1 reply; 6+ messages in thread
From: Hin-Tak Leung @ 2021-07-27 18:57 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Herton Ronaldo Krzesinski, Larry Finger, David S. Miller,
	Jakub Kicinski, gregkh, Salah Triki, linux-wireless, netdev,
	linux-kernel

> > 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>

Nacked-by: Hin-Tak Leung <htl10@users.sourceforge.net>

Seeing as the change does not add any value.

> >> ---
> >> 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).

Yes, sorry about that (I got a few bounces). Yahoo (where this is coming from) seems to make it quite hard to send plain non-html e-mails. See if this one gets through.


> -- 
> https://patchwork.kernel.org/project/linux-wireless/list/

> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wireless: rtl8187: replace udev with usb_get_dev()
  2021-07-27 18:57 ` [PATCH] wireless: rtl8187: replace udev with usb_get_dev() Hin-Tak Leung
@ 2021-07-28  7:13   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2021-07-28  7:13 UTC (permalink / raw)
  To: Hin-Tak Leung
  Cc: Herton Ronaldo Krzesinski, Larry Finger, David S. Miller,
	Jakub Kicinski, gregkh, Salah Triki, linux-wireless, netdev,
	linux-kernel

Hin-Tak Leung <htl10@users.sourceforge.net> writes:

>> BTW, please don't use HTML in emails. Our lists drop all HTML mail (and
>> for a good reason).
>
> Yes, sorry about that (I got a few bounces). Yahoo (where this is
> coming from) seems to make it quite hard to send plain non-html
> e-mails. See if this one gets through.

This one looks ok to me:

Content-Type: text/plain; charset=UTF-8

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wireless: rtl8187: replace udev with usb_get_dev()
       [not found] ` <53895498.1259278.1627160074135@mail.yahoo.com>
  2021-07-25  6:33   ` Greg KH
  2021-07-25 19:46   ` Larry Finger
@ 2021-07-27  6:10   ` Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2021-07-27  6:10 UTC (permalink / raw)
  To: Hin-Tak Leung
  Cc: Herton Ronaldo Krzesinski, Larry Finger, David S. Miller,
	Jakub Kicinski, gregkh, Salah Triki, linux-wireless, netdev,
	linux-kernel

Hin-Tak Leung <htl10@users.sourceforge.net> writes:

> 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? 

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wireless: rtl8187: replace udev with usb_get_dev()
       [not found] ` <53895498.1259278.1627160074135@mail.yahoo.com>
  2021-07-25  6:33   ` Greg KH
@ 2021-07-25 19:46   ` Larry Finger
  2021-07-27  6:10   ` Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Larry Finger @ 2021-07-25 19:46 UTC (permalink / raw)
  To: htl10, Herton Ronaldo Krzesinski, Kalle Valo, David S. Miller,
	Jakub Kicinski, gregkh, Salah Triki
  Cc: linux-wireless, netdev, linux-kernel

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wireless: rtl8187: replace udev with usb_get_dev()
       [not found] ` <53895498.1259278.1627160074135@mail.yahoo.com>
@ 2021-07-25  6:33   ` Greg KH
  2021-07-25 19:46   ` Larry Finger
  2021-07-27  6:10   ` Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-07-25  6:33 UTC (permalink / raw)
  To: Hin-Tak Leung
  Cc: Herton Ronaldo Krzesinski, Larry Finger, Kalle Valo,
	David S. Miller, Jakub Kicinski, Salah Triki, linux-wireless,
	netdev, linux-kernel

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 <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.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] wireless: rtl8187: replace udev with usb_get_dev()
@ 2021-07-24 18:34 Salah Triki
       [not found] ` <53895498.1259278.1627160074135@mail.yahoo.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Salah Triki @ 2021-07-24 18:34 UTC (permalink / raw)
  To: Herton Ronaldo Krzesinski, Hin-Tak Leung, Larry Finger,
	Kalle Valo, David S. Miller, Jakub Kicinski, gregkh
  Cc: linux-wireless, netdev, linux-kernel

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-28  7:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1490129435.403938.1627412276697.ref@mail.yahoo.com>
2021-07-27 18:57 ` [PATCH] wireless: rtl8187: replace udev with usb_get_dev() Hin-Tak Leung
2021-07-28  7:13   ` Kalle Valo
2021-07-24 18:34 Salah Triki
     [not found] ` <53895498.1259278.1627160074135@mail.yahoo.com>
2021-07-25  6:33   ` Greg KH
2021-07-25 19:46   ` Larry Finger
2021-07-27  6:10   ` Kalle Valo

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).