]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
USB: usbsevseg: drop redundant device reference
authorJohan Hovold <johan@kernel.org>
Thu, 5 Mar 2026 11:15:11 +0000 (12:15 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 Mar 2026 14:14:35 +0000 (15:14 +0100)
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/20260305111511.18386-6-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/usbsevseg.c

index b37bf53dd54f13b0feaece2f53bf84bb4258bd40..89d25fcef6424b54b7616bfe88f1e108fcdff257 100644 (file)
@@ -312,7 +312,7 @@ static int sevseg_probe(struct usb_interface *interface,
        if (!mydev)
                goto error_mem;
 
-       mydev->udev = usb_get_dev(udev);
+       mydev->udev = udev;
        mydev->intf = interface;
        usb_set_intfdata(interface, mydev);
 
@@ -338,7 +338,6 @@ static void sevseg_disconnect(struct usb_interface *interface)
 
        mydev = usb_get_intfdata(interface);
        usb_set_intfdata(interface, NULL);
-       usb_put_dev(mydev->udev);
        kfree(mydev);
        dev_info(&interface->dev, "USB 7 Segment now disconnected\n");
 }