[PATCH] mfd: viperboard: drop redundant device reference

Johan Hovold posted 1 patch 1 month ago
drivers/mfd/viperboard.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
[PATCH] mfd: viperboard: drop redundant device reference
Posted by Johan Hovold 1 month ago
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/mfd/viperboard.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/viperboard.c b/drivers/mfd/viperboard.c
index f964bcfa0796..888737b8e7be 100644
--- a/drivers/mfd/viperboard.c
+++ b/drivers/mfd/viperboard.c
@@ -59,7 +59,7 @@ static int vprbrd_probe(struct usb_interface *interface,
 
 	mutex_init(&vb->lock);
 
-	vb->usb_dev = usb_get_dev(interface_to_usbdev(interface));
+	vb->usb_dev = interface_to_usbdev(interface);
 
 	/* save our data pointer in this interface device */
 	usb_set_intfdata(interface, vb);
@@ -96,10 +96,8 @@ static int vprbrd_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (vb) {
-		usb_put_dev(vb->usb_dev);
+	if (vb)
 		kfree(vb);
-	}
 
 	return ret;
 }
@@ -110,7 +108,6 @@ static void vprbrd_disconnect(struct usb_interface *interface)
 
 	mfd_remove_devices(&interface->dev);
 	usb_set_intfdata(interface, NULL);
-	usb_put_dev(vb->usb_dev);
 	kfree(vb);
 
 	dev_dbg(&interface->dev, "disconnected\n");
-- 
2.52.0
Re: (subset) [PATCH] mfd: viperboard: drop redundant device reference
Posted by Lee Jones 1 month ago
On Thu, 05 Mar 2026 11:40:51 +0100, Johan Hovold wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] mfd: viperboard: drop redundant device reference
      commit: 84754c7240b202b1be494e3151c6bd72dc2273db

--
Lee Jones [李琼斯]