]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtl8xxxu: drop redundant device reference
authorJohan Hovold <johan@kernel.org>
Fri, 6 Mar 2026 08:51:43 +0000 (09:51 +0100)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 16 Mar 2026 05:59:59 +0000 (13:59 +0800)
Driver core holds a reference to the USB interface and its parent USB
device while the interface is bound to a driver and there is no need to
take additional references unless the structures are needed after
disconnect.

Drop the redundant device reference to reduce cargo culting, make it
easier to spot drivers where an extra reference is needed, and reduce
the risk of memory leaks when drivers fail to release it.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260306085144.12064-18-johan@kernel.org
drivers/net/wireless/realtek/rtl8xxxu/core.c

index d1b1474cba6771268135d4a19feaddc985061c2d..cb6c8859a918f2d9b1e7b69cb941510df9dbc0fe 100644 (file)
@@ -7686,7 +7686,7 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
        int ret;
        int untested = 1;
 
-       udev = usb_get_dev(interface_to_usbdev(interface));
+       udev = interface_to_usbdev(interface);
 
        switch (id->idVendor) {
        case USB_VENDOR_ID_REALTEK:
@@ -7745,10 +7745,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
        }
 
        hw = ieee80211_alloc_hw(sizeof(struct rtl8xxxu_priv), &rtl8xxxu_ops);
-       if (!hw) {
-               ret = -ENOMEM;
-               goto err_put_dev;
-       }
+       if (!hw)
+               return -ENOMEM;
 
        priv = hw->priv;
        priv->hw = hw;
@@ -7890,8 +7888,6 @@ err_set_intfdata:
        mutex_destroy(&priv->h2c_mutex);
 
        ieee80211_free_hw(hw);
-err_put_dev:
-       usb_put_dev(udev);
 
        return ret;
 }
@@ -7924,7 +7920,6 @@ static void rtl8xxxu_disconnect(struct usb_interface *interface)
                         "Device still attached, trying to reset\n");
                usb_reset_device(priv->udev);
        }
-       usb_put_dev(priv->udev);
        ieee80211_free_hw(hw);
 }