Skip to contentSkip to conversation

USB: usbip: missing lock in stub down

PATCH In review Jose Ignacio Tornos Martinez 2 participants 2 messages Oct 3, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: usbip: missing lock in stub down

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.

---
 drivers/usb/usbip/stub_dev.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/usbip/stub_dev.c +2 -0
index 3c6d452e3bf4..b4b452ce7120 100644
@@ -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;
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Jose Ignacio Tornos Martinez

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.

---
  drivers/usb/usbip/stub_dev.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/usb/usbip/stub_dev.c +0 -0
index 3c6d452e3bf4..b4b452ce7120 100644

drivers/usb/usbip/stub_dev.c static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a · line 125

Quoted 8 lines
drivers/usb/usbip/stub_dev.c +2 -0
@@ -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;

The change looks good to me. Please run get_miantainers.pl to include all the maintainers in the future.

Greg, Please pick this up.

thanks,
-- Shuah