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: agilent_82357a: 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-2-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
d35da40e 04576813

+1 -4
+1 -4
drivers/gpib/agilent_82357a/agilent_82357a.c
··· 1479 1479 1480 1480 if (mutex_lock_interruptible(&agilent_82357a_hotplug_lock)) 1481 1481 return -ERESTARTSYS; 1482 - usb_dev = usb_get_dev(interface_to_usbdev(interface)); 1482 + usb_dev = interface_to_usbdev(interface); 1483 1483 for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i) { 1484 1484 if (!agilent_82357a_driver_interfaces[i]) { 1485 1485 agilent_82357a_driver_interfaces[i] = interface; ··· 1490 1490 } 1491 1491 } 1492 1492 if (i == MAX_NUM_82357A_INTERFACES) { 1493 - usb_put_dev(usb_dev); 1494 1493 mutex_unlock(&agilent_82357a_hotplug_lock); 1495 1494 dev_err(&usb_dev->dev, "out of space in agilent_82357a_driver_interfaces[]\n"); 1496 1495 return -1; 1497 1496 } 1498 1497 path = kmalloc(path_length, GFP_KERNEL); 1499 1498 if (!path) { 1500 - usb_put_dev(usb_dev); 1501 1499 mutex_unlock(&agilent_82357a_hotplug_lock); 1502 1500 return -ENOMEM; 1503 1501 } ··· 1537 1539 } 1538 1540 if (i == MAX_NUM_82357A_INTERFACES) 1539 1541 dev_err(&usb_dev->dev, "unable to find interface - bug?\n"); 1540 - usb_put_dev(usb_dev); 1541 1542 1542 1543 mutex_unlock(&agilent_82357a_hotplug_lock); 1543 1544 }