Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpib: ni_usb: drop redundant device reference

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>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
678f946b d35da40e

-4
-4
drivers/gpib/ni_usb/ni_usb_gpib.c
··· 2431 2431 static const int path_length = 1024; 2432 2432 2433 2433 mutex_lock(&ni_usb_hotplug_lock); 2434 - usb_get_dev(usb_dev); 2435 2434 for (i = 0; i < MAX_NUM_NI_USB_INTERFACES; i++) { 2436 2435 if (!ni_usb_driver_interfaces[i]) { 2437 2436 ni_usb_driver_interfaces[i] = interface; ··· 2439 2440 } 2440 2441 } 2441 2442 if (i == MAX_NUM_NI_USB_INTERFACES) { 2442 - usb_put_dev(usb_dev); 2443 2443 mutex_unlock(&ni_usb_hotplug_lock); 2444 2444 dev_err(&usb_dev->dev, "ni_usb_driver_interfaces[] full\n"); 2445 2445 return -1; 2446 2446 } 2447 2447 path = kmalloc(path_length, GFP_KERNEL); 2448 2448 if (!path) { 2449 - usb_put_dev(usb_dev); 2450 2449 mutex_unlock(&ni_usb_hotplug_lock); 2451 2450 return -ENOMEM; 2452 2451 } ··· 2485 2488 } 2486 2489 if (i == MAX_NUM_NI_USB_INTERFACES) 2487 2490 dev_err(&usb_dev->dev, "unable to find interface bug?\n"); 2488 - usb_put_dev(usb_dev); 2489 2491 mutex_unlock(&ni_usb_hotplug_lock); 2490 2492 } 2491 2493