]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: at76c50x: drop redundant device reference
authorJohan Hovold <johan@kernel.org>
Fri, 6 Mar 2026 08:51:32 +0000 (09:51 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 6 Mar 2026 09:55:28 +0000 (10:55 +0100)
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>
Link: https://patch.msgid.link/20260306085144.12064-7-johan@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/atmel/at76c50x-usb.c

index 6445332801a4cfd5e930e84b3818f5a6290064fb..44b04ea3cc8b06d376217ca8538ba459c605e372 100644 (file)
@@ -2440,13 +2440,11 @@ static int at76_probe(struct usb_interface *interface,
        struct mib_fw_version *fwv;
        int board_type = (int)id->driver_info;
 
-       udev = usb_get_dev(interface_to_usbdev(interface));
+       udev = interface_to_usbdev(interface);
 
        fwv = kmalloc_obj(*fwv);
-       if (!fwv) {
-               ret = -ENOMEM;
-               goto exit;
-       }
+       if (!fwv)
+               return -ENOMEM;
 
        /* Load firmware into kernel memory */
        fwe = at76_load_firmware(udev, board_type);
@@ -2534,8 +2532,7 @@ static int at76_probe(struct usb_interface *interface,
 
 exit:
        kfree(fwv);
-       if (ret < 0)
-               usb_put_dev(udev);
+
        return ret;
 }
 
@@ -2552,7 +2549,6 @@ static void at76_disconnect(struct usb_interface *interface)
 
        wiphy_info(priv->hw->wiphy, "disconnecting\n");
        at76_delete_device(priv);
-       usb_put_dev(interface_to_usbdev(interface));
        dev_info(&interface->dev, "disconnected\n");
 }