diff mbox series

USB: usbip: missing lock in stub down

Message ID 20221003091016.641900-1-jtornosm@redhat.com
State New
Headers show
Series USB: usbip: missing lock in stub down | expand

Commit Message

Jose Ignacio Tornos Martinez Oct. 3, 2022, 9:10 a.m. UTC
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>
---
 drivers/usb/usbip/stub_dev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Shuah Khan Oct. 3, 2022, 5:25 p.m. UTC | #1
On 10/3/22 03:10, Jose Ignacio Tornos Martinez wrote:
> 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>
> ---
>   drivers/usb/usbip/stub_dev.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
> index 3c6d452e3bf4..b4b452ce7120 100644
> --- a/drivers/usb/usbip/stub_dev.c
> +++ b/drivers/usb/usbip/stub_dev.c
> @@ -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.

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

Greg, Please pick this up.

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
index 3c6d452e3bf4..b4b452ce7120 100644
--- a/drivers/usb/usbip/stub_dev.c
+++ b/drivers/usb/usbip/stub_dev.c
@@ -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;