]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nfc: port100: drop redundant device reference
authorJohan Hovold <johan@kernel.org>
Thu, 5 Mar 2026 11:10:19 +0000 (12:10 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 7 Mar 2026 02:57:42 +0000 (18:57 -0800)
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/20260305111019.18030-3-johan@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/nfc/port100.c

index a922569d7b48bff8f0468aa60f7417b72d9684bd..09dcc6f4c4f38d3f636643bf06bff618753bcc20 100644 (file)
@@ -1504,7 +1504,7 @@ static int port100_probe(struct usb_interface *interface,
                return -ENOMEM;
 
        mutex_init(&dev->out_urb_lock);
-       dev->udev = usb_get_dev(interface_to_usbdev(interface));
+       dev->udev = interface_to_usbdev(interface);
        dev->interface = interface;
        usb_set_intfdata(interface, dev);
 
@@ -1616,7 +1616,6 @@ error:
        usb_free_urb(dev->in_urb);
        usb_kill_urb(dev->out_urb);
        usb_free_urb(dev->out_urb);
-       usb_put_dev(dev->udev);
 
        return rc;
 }
@@ -1636,7 +1635,6 @@ static void port100_disconnect(struct usb_interface *interface)
 
        usb_free_urb(dev->in_urb);
        usb_free_urb(dev->out_urb);
-       usb_put_dev(dev->udev);
 
        kfree(dev->cmd);