* [PATCH 1/5] USB: cypress_cy7c63: drop redundant device reference
2026-03-05 11:15 [PATCH 0/5] USB: drop redundant references Johan Hovold
@ 2026-03-05 11:15 ` Johan Hovold
2026-03-05 11:15 ` [PATCH 2/5] USB: cytherm: " Johan Hovold
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2026-03-05 11:15 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Lixu Zhang, Sakari Ailus, linux-usb, 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/usb/misc/cypress_cy7c63.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c
index 99185fc3e9df..4a7f955ba85b 100644
--- a/drivers/usb/misc/cypress_cy7c63.c
+++ b/drivers/usb/misc/cypress_cy7c63.c
@@ -215,7 +215,7 @@ static int cypress_probe(struct usb_interface *interface,
if (!dev)
goto error_mem;
- dev->udev = usb_get_dev(interface_to_usbdev(interface));
+ dev->udev = interface_to_usbdev(interface);
/* save our data pointer in this interface device */
usb_set_intfdata(interface, dev);
@@ -239,8 +239,6 @@ static void cypress_disconnect(struct usb_interface *interface)
* device files have been removed */
usb_set_intfdata(interface, NULL);
- usb_put_dev(dev->udev);
-
dev_info(&interface->dev,
"Cypress CY7C63xxx device now disconnected\n");
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/5] USB: cytherm: drop redundant device reference
2026-03-05 11:15 [PATCH 0/5] USB: drop redundant references Johan Hovold
2026-03-05 11:15 ` [PATCH 1/5] USB: cypress_cy7c63: drop redundant device reference Johan Hovold
@ 2026-03-05 11:15 ` Johan Hovold
2026-03-05 11:15 ` [PATCH 3/5] USB: ljca: drop redundant interface reference Johan Hovold
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2026-03-05 11:15 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Lixu Zhang, Sakari Ailus, linux-usb, 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/usb/misc/cytherm.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index 2bf082474e9d..b183df9826bc 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -311,7 +311,7 @@ static int cytherm_probe(struct usb_interface *interface,
if (!dev)
goto error_mem;
- dev->udev = usb_get_dev(udev);
+ dev->udev = udev;
usb_set_intfdata(interface, dev);
@@ -334,8 +334,6 @@ static void cytherm_disconnect(struct usb_interface *interface)
/* first remove the files, then NULL the pointer */
usb_set_intfdata(interface, NULL);
- usb_put_dev(dev->udev);
-
kfree(dev);
dev_info(&interface->dev, "Cypress thermometer now disconnected\n");
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/5] USB: ljca: drop redundant interface reference
2026-03-05 11:15 [PATCH 0/5] USB: drop redundant references Johan Hovold
2026-03-05 11:15 ` [PATCH 1/5] USB: cypress_cy7c63: drop redundant device reference Johan Hovold
2026-03-05 11:15 ` [PATCH 2/5] USB: cytherm: " Johan Hovold
@ 2026-03-05 11:15 ` Johan Hovold
2026-03-05 13:18 ` Sakari Ailus
2026-03-05 11:15 ` [PATCH 4/5] USB: trancevibrator: drop redundant device reference Johan Hovold
2026-03-05 11:15 ` [PATCH 5/5] USB: usbsevseg: " Johan Hovold
4 siblings, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2026-03-05 11:15 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Lixu Zhang, Sakari Ailus, linux-usb, linux-kernel, Johan Hovold
Driver core holds a reference to the USB interface while it is bound to
a driver and there is no need to take another reference unless the
interface is needed after disconnect.
Drop the redundant interface 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/usb/misc/usb-ljca.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/misc/usb-ljca.c b/drivers/usb/misc/usb-ljca.c
index 7e85fd12da56..c60121faa3da 100644
--- a/drivers/usb/misc/usb-ljca.c
+++ b/drivers/usb/misc/usb-ljca.c
@@ -776,7 +776,7 @@ static int ljca_probe(struct usb_interface *interface,
init_completion(&adap->cmd_completion);
INIT_LIST_HEAD(&adap->client_list);
- adap->intf = usb_get_intf(interface);
+ adap->intf = interface;
adap->usb_dev = usb_dev;
adap->dev = dev;
@@ -787,7 +787,7 @@ static int ljca_probe(struct usb_interface *interface,
ret = usb_find_common_endpoints(alt, &ep_in, &ep_out, NULL, NULL);
if (ret) {
dev_err(dev, "bulk endpoints not found\n");
- goto err_put;
+ goto err_destroy_mutex;
}
adap->rx_pipe = usb_rcvbulkpipe(usb_dev, usb_endpoint_num(ep_in));
adap->tx_pipe = usb_sndbulkpipe(usb_dev, usb_endpoint_num(ep_out));
@@ -797,14 +797,14 @@ static int ljca_probe(struct usb_interface *interface,
adap->rx_buf = devm_kzalloc(dev, adap->rx_len, GFP_KERNEL);
if (!adap->rx_buf) {
ret = -ENOMEM;
- goto err_put;
+ goto err_destroy_mutex;
}
/* alloc rx urb */
adap->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!adap->rx_urb) {
ret = -ENOMEM;
- goto err_put;
+ goto err_destroy_mutex;
}
usb_fill_bulk_urb(adap->rx_urb, usb_dev, adap->rx_pipe,
adap->rx_buf, adap->rx_len, ljca_recv, adap);
@@ -836,10 +836,7 @@ static int ljca_probe(struct usb_interface *interface,
err_free:
usb_free_urb(adap->rx_urb);
-
-err_put:
- usb_put_intf(adap->intf);
-
+err_destroy_mutex:
mutex_destroy(&adap->mutex);
return ret;
@@ -864,8 +861,6 @@ static void ljca_disconnect(struct usb_interface *interface)
usb_free_urb(adap->rx_urb);
- usb_put_intf(adap->intf);
-
mutex_destroy(&adap->mutex);
}
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 3/5] USB: ljca: drop redundant interface reference
2026-03-05 11:15 ` [PATCH 3/5] USB: ljca: drop redundant interface reference Johan Hovold
@ 2026-03-05 13:18 ` Sakari Ailus
0 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2026-03-05 13:18 UTC (permalink / raw)
To: Johan Hovold; +Cc: Greg Kroah-Hartman, Lixu Zhang, linux-usb, linux-kernel
Hi Johan,
Thanks for the patch.
On Thu, Mar 05, 2026 at 12:15:09PM +0100, Johan Hovold wrote:
> Driver core holds a reference to the USB interface while it is bound to
> a driver and there is no need to take another reference unless the
> interface is needed after disconnect.
>
> Drop the redundant interface 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>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] USB: trancevibrator: drop redundant device reference
2026-03-05 11:15 [PATCH 0/5] USB: drop redundant references Johan Hovold
` (2 preceding siblings ...)
2026-03-05 11:15 ` [PATCH 3/5] USB: ljca: drop redundant interface reference Johan Hovold
@ 2026-03-05 11:15 ` Johan Hovold
2026-03-05 11:15 ` [PATCH 5/5] USB: usbsevseg: " Johan Hovold
4 siblings, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2026-03-05 11:15 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Lixu Zhang, Sakari Ailus, linux-usb, 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/usb/misc/trancevibrator.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index 6aaec2db360b..37f6b79889a6 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -92,7 +92,7 @@ static int tv_probe(struct usb_interface *interface,
goto error;
}
- dev->udev = usb_get_dev(udev);
+ dev->udev = udev;
usb_set_intfdata(interface, dev);
return 0;
@@ -108,7 +108,6 @@ static void tv_disconnect(struct usb_interface *interface)
dev = usb_get_intfdata (interface);
usb_set_intfdata(interface, NULL);
- usb_put_dev(dev->udev);
kfree(dev);
}
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/5] USB: usbsevseg: drop redundant device reference
2026-03-05 11:15 [PATCH 0/5] USB: drop redundant references Johan Hovold
` (3 preceding siblings ...)
2026-03-05 11:15 ` [PATCH 4/5] USB: trancevibrator: drop redundant device reference Johan Hovold
@ 2026-03-05 11:15 ` Johan Hovold
4 siblings, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2026-03-05 11:15 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Lixu Zhang, Sakari Ailus, linux-usb, 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/usb/misc/usbsevseg.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
index b37bf53dd54f..89d25fcef642 100644
--- a/drivers/usb/misc/usbsevseg.c
+++ b/drivers/usb/misc/usbsevseg.c
@@ -312,7 +312,7 @@ static int sevseg_probe(struct usb_interface *interface,
if (!mydev)
goto error_mem;
- mydev->udev = usb_get_dev(udev);
+ mydev->udev = udev;
mydev->intf = interface;
usb_set_intfdata(interface, mydev);
@@ -338,7 +338,6 @@ static void sevseg_disconnect(struct usb_interface *interface)
mydev = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL);
- usb_put_dev(mydev->udev);
kfree(mydev);
dev_info(&interface->dev, "USB 7 Segment now disconnected\n");
}
--
2.52.0
^ permalink raw reply related [flat|nested] 7+ messages in thread