Skip to contentSkip to conversation

mfd: viperboard: drop redundant device reference

PATCH Applied Johan Hovold 2 participants 2 messages Mar 5 – Mar 9 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: viperboard: 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.

---
 drivers/mfd/viperboard.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/viperboard.c +2 -5
index f964bcfa0796..888737b8e7be 100644
@@ -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");
Signature · 1 line
2.52.0
maintainer Applied
#1 lore raw

Re: (subset) [PATCH] mfd: viperboard: drop redundant device reference

Quoted 10 lines · 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.

[...]

Applied, thanks!

[1/1] mfd: viperboard: drop redundant device reference

      commit: 84754c7240b202b1be494e3151c6bd72dc2273db

--
Lee Jones [李琼斯]