* [PATCH 0/2] gpib: drop redundant device reference
@ 2026-03-05 10:27 Johan Hovold
2026-03-05 10:27 ` [PATCH 1/2] gpib: agilent_82357a: " Johan Hovold
2026-03-05 10:27 ` [PATCH 2/2] gpib: ni_usb: " Johan Hovold
0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2026-03-05 10:27 UTC (permalink / raw)
To: Dave Penkler; +Cc: Greg Kroah-Hartman, linux-kernel, Johan Hovold
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.
Johan
Johan Hovold (2):
gpib: agilent_82357a: drop redundant device reference
gpib: ni_usb: drop redundant device reference
drivers/gpib/agilent_82357a/agilent_82357a.c | 5 +----
drivers/gpib/ni_usb/ni_usb_gpib.c | 4 ----
2 files changed, 1 insertion(+), 8 deletions(-)
--
2.52.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] gpib: agilent_82357a: drop redundant device reference
2026-03-05 10:27 [PATCH 0/2] gpib: drop redundant device reference Johan Hovold
@ 2026-03-05 10:27 ` Johan Hovold
2026-03-05 10:27 ` [PATCH 2/2] gpib: ni_usb: " Johan Hovold
1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2026-03-05 10:27 UTC (permalink / raw)
To: Dave Penkler; +Cc: Greg Kroah-Hartman, linux-kernel, Johan Hovold
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>
---
drivers/gpib/agilent_82357a/agilent_82357a.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/gpib/agilent_82357a/agilent_82357a.c b/drivers/gpib/agilent_82357a/agilent_82357a.c
index e1349afbf933..770ba6eb40d1 100644
--- a/drivers/gpib/agilent_82357a/agilent_82357a.c
+++ b/drivers/gpib/agilent_82357a/agilent_82357a.c
@@ -1479,7 +1479,7 @@ static int agilent_82357a_driver_probe(struct usb_interface *interface,
if (mutex_lock_interruptible(&agilent_82357a_hotplug_lock))
return -ERESTARTSYS;
- usb_dev = usb_get_dev(interface_to_usbdev(interface));
+ usb_dev = interface_to_usbdev(interface);
for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i) {
if (!agilent_82357a_driver_interfaces[i]) {
agilent_82357a_driver_interfaces[i] = interface;
@@ -1490,14 +1490,12 @@ static int agilent_82357a_driver_probe(struct usb_interface *interface,
}
}
if (i == MAX_NUM_82357A_INTERFACES) {
- usb_put_dev(usb_dev);
mutex_unlock(&agilent_82357a_hotplug_lock);
dev_err(&usb_dev->dev, "out of space in agilent_82357a_driver_interfaces[]\n");
return -1;
}
path = kmalloc(path_length, GFP_KERNEL);
if (!path) {
- usb_put_dev(usb_dev);
mutex_unlock(&agilent_82357a_hotplug_lock);
return -ENOMEM;
}
@@ -1539,7 +1537,6 @@ static void agilent_82357a_driver_disconnect(struct usb_interface *interface)
}
if (i == MAX_NUM_82357A_INTERFACES)
dev_err(&usb_dev->dev, "unable to find interface - bug?\n");
- usb_put_dev(usb_dev);
mutex_unlock(&agilent_82357a_hotplug_lock);
}
--
2.52.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] gpib: ni_usb: drop redundant device reference
2026-03-05 10:27 [PATCH 0/2] gpib: drop redundant device reference Johan Hovold
2026-03-05 10:27 ` [PATCH 1/2] gpib: agilent_82357a: " Johan Hovold
@ 2026-03-05 10:27 ` Johan Hovold
1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2026-03-05 10:27 UTC (permalink / raw)
To: Dave Penkler; +Cc: Greg Kroah-Hartman, linux-kernel, Johan Hovold
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>
---
drivers/gpib/ni_usb/ni_usb_gpib.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/gpib/ni_usb/ni_usb_gpib.c b/drivers/gpib/ni_usb/ni_usb_gpib.c
index a24cd6521362..0bbc13ecebf9 100644
--- a/drivers/gpib/ni_usb/ni_usb_gpib.c
+++ b/drivers/gpib/ni_usb/ni_usb_gpib.c
@@ -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);
}
--
2.52.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-05 10:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-05 10:27 [PATCH 0/2] gpib: drop redundant device reference Johan Hovold
2026-03-05 10:27 ` [PATCH 1/2] gpib: agilent_82357a: " Johan Hovold
2026-03-05 10:27 ` [PATCH 2/2] gpib: ni_usb: " Johan Hovold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox