Thread (1 message) 1 message, 1 author, 2021-07-25

Re: [PATCH] wireless: rtl8187: replace udev with usb_get_dev()

From: Greg KH <gregkh@linuxfoundation.org>
Date: 2021-07-25 06:33:08
Also in: lkml, netdev

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 [off-list ref] wrote:

quoted
Replace udev with usb_get_dev() in order to make code cleaner.
quoted
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(-)
quoted
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,
quoted
    SET_IEEE80211_DEV(dev, &intf->dev);
    usb_set_intfdata(intf, dev);
-    priv->udev = udev;
-
-    usb_get_dev(udev);
+    priv->udev = usb_get_dev(udev);
quoted
    skb_queue_head_init(&priv->rx_queue);
quoted
-- 
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help