Skip to contentSkip to conversation

scsi: Fix setting device state to running

PATCH Applied Mike Christie 3 participants 3 messages Nov 20, 2021 – Nov 23, 2021 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: Fix setting device state to running

This fixes an issue added in:

commit 4edd8cd4e86d ("scsi: core: sysfs: Fix hang when device state is set via sysfs")

where if userspace is requesting to set the device state to SDEV_RUNNING when the state is already SDEV_RUNNING, we return -EINVAL instead of count. The commmit above set ret to count for this case, when it should have set it to 0.

Fixes 4edd8cd4e86d ("scsi: core: sysfs: Fix hang when device state is set

via sysfs")

---
 drivers/scsi/scsi_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_sysfs.c +1 -1
index 7afcec250f9b..d4edce930a4a 100644
@@ -812,7 +812,7 @@ store_state_field(struct device *dev, struct device_attribute *attr,
 
 	mutex_lock(&sdev->state_mutex);
 	if (sdev->sdev_state == SDEV_RUNNING && state == SDEV_RUNNING) {
-		ret = count;
+		ret = 0;
 	} else {
 		ret = scsi_device_set_state(sdev, state);
 		if (ret == 0 && state == SDEV_RUNNING)
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Mike Christie

This fixes an issue added in:

commit 4edd8cd4e86d ("scsi: core: sysfs: Fix hang when device state is set via sysfs")

where if userspace is requesting to set the device state to SDEV_RUNNING when the state is already SDEV_RUNNING, we return -EINVAL instead of count. The commmit above set ret to count for this case, when it should have set it to 0.

Fixes 4edd8cd4e86d ("scsi: core: sysfs: Fix hang when device state is set

via sysfs")

---
 drivers/scsi/scsi_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_sysfs.c +0 -0
index 7afcec250f9b..d4edce930a4a 100644

drivers/scsi/scsi_sysfs.c store_state_field(struct device *dev, struct device_attribute *attr, · line 818

Quoted 8 lines
drivers/scsi/scsi_sysfs.c +1 -1
@@ -812,7 +812,7 @@ store_state_field(struct device *dev, struct device_attribute *attr,
 
 	mutex_lock(&sdev->state_mutex);
 	if (sdev->sdev_state == SDEV_RUNNING && state == SDEV_RUNNING) {
-		ret = count;
+		ret = 0;
 	} else {
 		ret = scsi_device_set_state(sdev, state);
 		if (ret == 0 && state == SDEV_RUNNING)
#2 lore raw
In reply to Mike Christie
Quoted 11 lines · Mike Christie

This fixes an issue added in:

commit 4edd8cd4e86d ("scsi: core: sysfs: Fix hang when device state is set via sysfs")

where if userspace is requesting to set the device state to SDEV_RUNNING when the state is already SDEV_RUNNING, we return -EINVAL instead of count. The commmit above set ret to count for this case, when it should have set it to 0.

[...]

Applied to 5.16/scsi-fixes, thanks!

[1/1] scsi: Fix setting device state to running

      https://git.kernel.org/mkp/scsi/c/eb97545d6264
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering