]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
USB: usbip: missing lock in stub down
authorJose Ignacio Tornos Martinez <jtornosm@redhat.com>
Mon, 3 Oct 2022 09:10:16 +0000 (11:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Oct 2022 11:22:25 +0000 (13:22 +0200)
Missing lock in sysfs operation when we want to close the connection in order
to check the status and send the down event in a safe way.

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20221003091016.641900-1-jtornosm@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usbip/stub_dev.c

index f92047d860f07e404fcfa356e4a3c43bb19173b2..9c6954aad6c882c804f0750fd9f939623362521a 100644 (file)
@@ -118,6 +118,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
        } else {
                dev_info(dev, "stub down\n");
 
+               mutex_lock(&sdev->ud.sysfs_lock);
+
                spin_lock_irq(&sdev->ud.lock);
                if (sdev->ud.status != SDEV_ST_USED)
                        goto err;