]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gpib: ni_usb: drop redundant device reference
authorJohan Hovold <johan@kernel.org>
Thu, 5 Mar 2026 10:27:45 +0000 (11:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Mar 2026 10:48:54 +0000 (11:48 +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/20260305102745.12032-3-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpib/ni_usb/ni_usb_gpib.c

index a24cd65213620f5e78d5c625ed302b2860a88d4b..0bbc13ecebf910f65fb8aa57d5bd9da0b7493a7f 100644 (file)
@@ -2431,7 +2431,6 @@ static int ni_usb_driver_probe(struct usb_interface *interface,   const struct usb
        static const int path_length = 1024;
 
        mutex_lock(&ni_usb_hotplug_lock);
-       usb_get_dev(usb_dev);
        for (i = 0; i < MAX_NUM_NI_USB_INTERFACES; i++) {
                if (!ni_usb_driver_interfaces[i]) {
                        ni_usb_driver_interfaces[i] = interface;
@@ -2440,14 +2439,12 @@ static int ni_usb_driver_probe(struct usb_interface *interface, const struct usb
                }
        }
        if (i == MAX_NUM_NI_USB_INTERFACES) {
-               usb_put_dev(usb_dev);
                mutex_unlock(&ni_usb_hotplug_lock);
                dev_err(&usb_dev->dev, "ni_usb_driver_interfaces[] full\n");
                return -1;
        }
        path = kmalloc(path_length, GFP_KERNEL);
        if (!path) {
-               usb_put_dev(usb_dev);
                mutex_unlock(&ni_usb_hotplug_lock);
                return -ENOMEM;
        }
@@ -2488,7 +2485,6 @@ static void ni_usb_driver_disconnect(struct usb_interface *interface)
        }
        if (i == MAX_NUM_NI_USB_INTERFACES)
                dev_err(&usb_dev->dev, "unable to find interface  bug?\n");
-       usb_put_dev(usb_dev);
        mutex_unlock(&ni_usb_hotplug_lock);
 }