mfd: viperboard: drop redundant device reference
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
@@ -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
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 [李琼斯]