]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usbip: usbip_host: fix to hold parent lock for device_attach() calls
authorShuah Khan <shuahkh@osg.samsung.com>
Thu, 5 Apr 2018 22:29:04 +0000 (16:29 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 22 Apr 2018 12:45:11 +0000 (14:45 +0200)
usbip_host calls device_attach() without holding dev->parent lock.
Fix it.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usbip/stub_main.c

index c31c8402a0c55ddd2f4b463ebabd28be6438f490..d41d0cdeec0f2a1861d8d42385a9719789cab558 100644 (file)
@@ -186,7 +186,12 @@ static ssize_t rebind_store(struct device_driver *dev, const char *buf,
        if (!bid)
                return -ENODEV;
 
+       /* device_attach() callers should hold parent lock for USB */
+       if (bid->udev->dev.parent)
+               device_lock(bid->udev->dev.parent);
        ret = device_attach(&bid->udev->dev);
+       if (bid->udev->dev.parent)
+               device_unlock(bid->udev->dev.parent);
        if (ret < 0) {
                dev_err(&bid->udev->dev, "rebind failed\n");
                return ret;