]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtlwifi: usb: drop redundant device reference
authorJohan Hovold <johan@kernel.org>
Mon, 9 Mar 2026 08:33:36 +0000 (09:33 +0100)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 16 Mar 2026 06:06:11 +0000 (14:06 +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/20260309083336.16397-1-johan@kernel.org
drivers/net/wireless/realtek/rtlwifi/usb.c

index d35ed56d6db90a46d309a507d67ffcd52f6c093b..9a64df9eed39b7c42cc2d170ae58bd4bc56e52f3 100644 (file)
@@ -986,7 +986,6 @@ int rtl_usb_probe(struct usb_interface *intf,
        init_completion(&rtlpriv->firmware_loading_complete);
        SET_IEEE80211_DEV(hw, &intf->dev);
        udev = interface_to_usbdev(intf);
-       usb_get_dev(udev);
        usb_priv = rtl_usbpriv(hw);
        memset(usb_priv, 0, sizeof(*usb_priv));
        usb_priv->dev.intf = intf;
@@ -1038,7 +1037,6 @@ error_out:
        rtl_deinit_core(hw);
 error_out2:
        _rtl_usb_io_handler_release(hw);
-       usb_put_dev(udev);
        kfree(rtlpriv->usb_data);
        ieee80211_free_hw(hw);
        return -ENODEV;
@@ -1050,7 +1048,6 @@ void rtl_usb_disconnect(struct usb_interface *intf)
        struct ieee80211_hw *hw = usb_get_intfdata(intf);
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
-       struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
 
        if (unlikely(!rtlpriv))
                return;
@@ -1072,7 +1069,6 @@ void rtl_usb_disconnect(struct usb_interface *intf)
        kfree(rtlpriv->usb_data);
        rtlpriv->cfg->ops->deinit_sw_vars(hw);
        _rtl_usb_io_handler_release(hw);
-       usb_put_dev(rtlusb->udev);
        usb_set_intfdata(intf, NULL);
        ieee80211_free_hw(hw);
 }