From: Shuah Khan Date: Thu, 5 Apr 2018 22:29:04 +0000 (-0600) Subject: usbip: usbip_host: fix to hold parent lock for device_attach() calls X-Git-Tag: v4.1.52~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dff14704cd1b0cc3b5ba1384c1b3101edd05f810;p=thirdparty%2Fkernel%2Fstable.git usbip: usbip_host: fix to hold parent lock for device_attach() calls [ Upstream commit 4bfb141bc01312a817d36627cc47c93f801c216d ] usbip_host calls device_attach() without holding dev->parent lock. Fix it. Signed-off-by: Shuah Khan Cc: stable Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c index 325b4c05acdd3..f761e02e75c9c 100644 --- a/drivers/usb/usbip/stub_main.c +++ b/drivers/usb/usbip/stub_main.c @@ -201,7 +201,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;