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.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260305104051.15727-1-johan@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
Johan Hovold 2026-03-05 11:40:51 +01:00 committed by Lee Jones
parent a2753f06e3
commit 1a408a6778

View File

@ -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");