public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] media: drop redundant device references
@ 2026-03-05 10:39 Johan Hovold
  2026-03-05 10:39 ` [PATCH 1/4] media: imon: " Johan Hovold
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Johan Hovold @ 2026-03-05 10:39 UTC (permalink / raw)
  To: Sean Young, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, 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 redundant device references to reduce cargo culting, make it easier
to spot drivers where extra references are needed, and reduce the risk
of memory leaks when drivers fail to release them.

Johan


Johan Hovold (4):
  media: imon: drop redundant device references
  media: mceusb: drop redundant device reference
  media: go7007-loader: drop redundant device reference
  media: usbtv: drop redundant device reference

 drivers/media/rc/imon.c                  | 13 +++----------
 drivers/media/rc/mceusb.c                |  4 +---
 drivers/media/usb/go7007/go7007-loader.c |  6 +-----
 drivers/media/usb/usbtv/usbtv-core.c     |  4 +---
 4 files changed, 6 insertions(+), 21 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] media: imon: drop redundant device references
  2026-03-05 10:39 [PATCH 0/4] media: drop redundant device references Johan Hovold
@ 2026-03-05 10:39 ` Johan Hovold
  2026-03-05 10:39 ` [PATCH 2/4] media: mceusb: drop redundant device reference Johan Hovold
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2026-03-05 10:39 UTC (permalink / raw)
  To: Sean Young, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, 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 references to reduce cargo culting, make it
easier to spot drivers where extra references are needed, and reduce the
risk of memory leaks when drivers fail to release them.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/media/rc/imon.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 7e92161105d5..ecea0085d411 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -2250,7 +2250,7 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf,
 	mutex_lock(&ictx->lock);
 
 	ictx->dev = dev;
-	ictx->usbdev_intf0 = usb_get_dev(interface_to_usbdev(intf));
+	ictx->usbdev_intf0 = interface_to_usbdev(intf);
 	ictx->rx_urb_intf0 = rx_urb;
 	ictx->tx_urb = tx_urb;
 	ictx->rf_device = false;
@@ -2308,7 +2308,6 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf,
 	usb_kill_urb(ictx->rx_urb_intf0);
 urb_submit_failed:
 find_endpoint_failed:
-	usb_put_dev(ictx->usbdev_intf0);
 	mutex_unlock(&ictx->lock);
 	usb_free_urb(tx_urb);
 tx_urb_alloc_failed:
@@ -2338,7 +2337,7 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf,
 		timer_setup(&ictx->ttimer, imon_touch_display_timeout, 0);
 	}
 
-	ictx->usbdev_intf1 = usb_get_dev(interface_to_usbdev(intf));
+	ictx->usbdev_intf1 = interface_to_usbdev(intf);
 	ictx->rx_urb_intf1 = rx_urb;
 
 	ret = -ENODEV;
@@ -2377,7 +2376,6 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf,
 		input_unregister_device(ictx->touch);
 touch_setup_failed:
 find_endpoint_failed:
-	usb_put_dev(ictx->usbdev_intf1);
 	ictx->usbdev_intf1 = NULL;
 	mutex_unlock(&ictx->lock);
 	usb_free_urb(rx_urb);
@@ -2426,7 +2424,7 @@ static int imon_probe(struct usb_interface *interface,
 	struct imon_context *ictx = NULL;
 	u16 vendor, product;
 
-	usbdev     = usb_get_dev(interface_to_usbdev(interface));
+	usbdev     = interface_to_usbdev(interface);
 	iface_desc = interface->cur_altsetting;
 	ifnum      = iface_desc->desc.bInterfaceNumber;
 	vendor     = le16_to_cpu(usbdev->descriptor.idVendor);
@@ -2495,12 +2493,9 @@ static int imon_probe(struct usb_interface *interface,
 		 vendor, product, ifnum,
 		 usbdev->bus->busnum, usbdev->devnum);
 
-	usb_put_dev(usbdev);
-
 	return 0;
 
 fail:
-	usb_put_dev(usbdev);
 	dev_err(dev, "unable to register, err %d\n", ret);
 
 	return ret;
@@ -2550,7 +2545,6 @@ static void imon_disconnect(struct usb_interface *interface)
 			else if (ictx->display_type == IMON_DISPLAY_TYPE_VFD)
 				usb_deregister_dev(interface, &imon_vfd_class);
 		}
-		usb_put_dev(ictx->usbdev_intf0);
 	} else {
 		ictx->dev_present_intf1 = false;
 		usb_kill_urb(ictx->rx_urb_intf1);
@@ -2558,7 +2552,6 @@ static void imon_disconnect(struct usb_interface *interface)
 			timer_delete_sync(&ictx->ttimer);
 			input_unregister_device(ictx->touch);
 		}
-		usb_put_dev(ictx->usbdev_intf1);
 	}
 
 	if (refcount_dec_and_test(&ictx->users))
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] media: mceusb: drop redundant device reference
  2026-03-05 10:39 [PATCH 0/4] media: drop redundant device references Johan Hovold
  2026-03-05 10:39 ` [PATCH 1/4] media: imon: " Johan Hovold
@ 2026-03-05 10:39 ` Johan Hovold
  2026-03-05 10:39 ` [PATCH 3/4] media: go7007-loader: " Johan Hovold
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2026-03-05 10:39 UTC (permalink / raw)
  To: Sean Young, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, 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/media/rc/mceusb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index ed55e9ec3c57..d9bdf0b9487a 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -1729,7 +1729,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
 		goto urb_in_alloc_fail;
 
 	ir->usbintf = intf;
-	ir->usbdev = usb_get_dev(dev);
+	ir->usbdev = dev;
 	ir->dev = &intf->dev;
 	ir->len_in = maxp;
 	ir->flags.microsoft_gen1 = is_microsoft_gen1;
@@ -1817,7 +1817,6 @@ static int mceusb_dev_probe(struct usb_interface *intf,
 	/* Error-handling path */
 rc_dev_fail:
 	cancel_work_sync(&ir->kevent);
-	usb_put_dev(ir->usbdev);
 	usb_kill_urb(ir->urb_in);
 	usb_free_urb(ir->urb_in);
 urb_in_alloc_fail:
@@ -1849,7 +1848,6 @@ static void mceusb_dev_disconnect(struct usb_interface *intf)
 	usb_kill_urb(ir->urb_in);
 	usb_free_urb(ir->urb_in);
 	usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in);
-	usb_put_dev(dev);
 
 	kfree(ir);
 }
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] media: go7007-loader: drop redundant device reference
  2026-03-05 10:39 [PATCH 0/4] media: drop redundant device references Johan Hovold
  2026-03-05 10:39 ` [PATCH 1/4] media: imon: " Johan Hovold
  2026-03-05 10:39 ` [PATCH 2/4] media: mceusb: drop redundant device reference Johan Hovold
@ 2026-03-05 10:39 ` Johan Hovold
  2026-03-05 10:39 ` [PATCH 4/4] media: usbtv: " Johan Hovold
       [not found] ` <69a98f03.050a0220.1fe09d.ec95@mx.google.com>
  4 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2026-03-05 10:39 UTC (permalink / raw)
  To: Sean Young, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, 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/media/usb/go7007/go7007-loader.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/media/usb/go7007/go7007-loader.c b/drivers/media/usb/go7007/go7007-loader.c
index 243aa0ad074c..5747e6e4f2d6 100644
--- a/drivers/media/usb/go7007/go7007-loader.c
+++ b/drivers/media/usb/go7007/go7007-loader.c
@@ -41,9 +41,7 @@ static int go7007_loader_probe(struct usb_interface *interface,
 	int ret;
 	int i;
 
-	usbdev = usb_get_dev(interface_to_usbdev(interface));
-	if (!usbdev)
-		goto failed2;
+	usbdev = interface_to_usbdev(interface);
 
 	if (usbdev->descriptor.bNumConfigurations != 1) {
 		dev_err(&interface->dev, "can't handle multiple config\n");
@@ -96,7 +94,6 @@ static int go7007_loader_probe(struct usb_interface *interface,
 	return 0;
 
 failed2:
-	usb_put_dev(usbdev);
 	dev_err(&interface->dev, "probe failed\n");
 	return -ENODEV;
 }
@@ -104,7 +101,6 @@ static int go7007_loader_probe(struct usb_interface *interface,
 static void go7007_loader_disconnect(struct usb_interface *interface)
 {
 	dev_info(&interface->dev, "disconnect\n");
-	usb_put_dev(interface_to_usbdev(interface));
 	usb_set_intfdata(interface, NULL);
 }
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] media: usbtv: drop redundant device reference
  2026-03-05 10:39 [PATCH 0/4] media: drop redundant device references Johan Hovold
                   ` (2 preceding siblings ...)
  2026-03-05 10:39 ` [PATCH 3/4] media: go7007-loader: " Johan Hovold
@ 2026-03-05 10:39 ` Johan Hovold
       [not found] ` <69a98f03.050a0220.1fe09d.ec95@mx.google.com>
  4 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2026-03-05 10:39 UTC (permalink / raw)
  To: Sean Young, Mauro Carvalho Chehab, Hans Verkuil
  Cc: linux-media, 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/media/usb/usbtv/usbtv-core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
index c4bfadbe63c9..6c4facf4f41a 100644
--- a/drivers/media/usb/usbtv/usbtv-core.c
+++ b/drivers/media/usb/usbtv/usbtv-core.c
@@ -91,7 +91,7 @@ static int usbtv_probe(struct usb_interface *intf,
 	if (usbtv == NULL)
 		return -ENOMEM;
 	usbtv->dev = dev;
-	usbtv->udev = usb_get_dev(interface_to_usbdev(intf));
+	usbtv->udev = interface_to_usbdev(intf);
 
 	usbtv->iso_size = size;
 
@@ -119,7 +119,6 @@ static int usbtv_probe(struct usb_interface *intf,
 
 usbtv_video_fail:
 	usb_set_intfdata(intf, NULL);
-	usb_put_dev(usbtv->udev);
 	kfree(usbtv);
 
 	return ret;
@@ -137,7 +136,6 @@ static void usbtv_disconnect(struct usb_interface *intf)
 	usbtv_audio_free(usbtv);
 	usbtv_video_free(usbtv);
 
-	usb_put_dev(usbtv->udev);
 	usbtv->udev = NULL;
 
 	/* the usbtv structure will be deallocated when v4l2 will be
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [0/4] media: drop redundant device references
       [not found] ` <69a98f03.050a0220.1fe09d.ec95@mx.google.com>
@ 2026-03-10  8:40   ` Johan Hovold
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2026-03-10  8:40 UTC (permalink / raw)
  To: linux-media

On Thu, Mar 05, 2026 at 06:11:15AM -0800, Patchwork Integration wrote:

> Thanks for your patches! Unfortunately the Media CI robot detected some
> issues:

> Please fix your series, and upload a new version. If you have a patchwork
> account, do not forget to mark the current series as Superseded.
> 
> For more details, check the full report at:
> https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/94563495/artifacts/report.htm .

> If you believe that the CI is wrong, kindly open an issue at
> https://gitlab.freedesktop.org/linux-media/media-ci/-/issues or reply-all
> to this message.

Judging from the link above it looks like the CI robot encountered some
internal error:

	ssh tunnel: read tcp 10.128.0.5:56668->10.128.0.18:22: read: connection reset by peer (%!s(<nil>))

Can someone please override the robot?

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-10  8:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 10:39 [PATCH 0/4] media: drop redundant device references Johan Hovold
2026-03-05 10:39 ` [PATCH 1/4] media: imon: " Johan Hovold
2026-03-05 10:39 ` [PATCH 2/4] media: mceusb: drop redundant device reference Johan Hovold
2026-03-05 10:39 ` [PATCH 3/4] media: go7007-loader: " Johan Hovold
2026-03-05 10:39 ` [PATCH 4/4] media: usbtv: " Johan Hovold
     [not found] ` <69a98f03.050a0220.1fe09d.ec95@mx.google.com>
2026-03-10  8:40   ` [0/4] media: drop redundant device references Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox