]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
USB: usbip: drop redundant device reference
authorJohan Hovold <johan@kernel.org>
Thu, 5 Mar 2026 13:38:51 +0000 (14:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Mar 2026 14:51:44 +0000 (15:51 +0100)
Driver core holds a reference to the USB device while it is bound to a
driver and there is no need to take additional references unless the
structure is 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/20260305133851.2952-3-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usbip/stub_dev.c

index 34990b7e2d189824ff1509e9b6ecda156ae86fcd..abfa11d6bde799489c99f5ea64273c5a3f9d476b 100644 (file)
@@ -267,7 +267,7 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev)
        if (!sdev)
                return NULL;
 
-       sdev->udev = usb_get_dev(udev);
+       sdev->udev = udev;
 
        /*
         * devid is defined with devnum when this driver is first allocated.
@@ -409,7 +409,6 @@ call_put_busid_priv:
        put_busid_priv(busid_priv);
 
 sdev_free:
-       usb_put_dev(udev);
        stub_device_free(sdev);
 
        return rc;
@@ -488,8 +487,6 @@ static void stub_disconnect(struct usb_device *udev)
        /* shutdown the current connection */
        shutdown_busid(busid_priv);
 
-       usb_put_dev(sdev->udev);
-
        /* we already have busid_priv, just lock busid_lock */
        spin_lock(&busid_priv->busid_lock);
        /* free sdev */