Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: core: sysfs: Fix setting device state to SDEV_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.

Link: https://lore.kernel.org/r/20211120164917.4924-1-michael.christie@oracle.com
Fixes: 4edd8cd4e86d ("scsi: core: sysfs: Fix hang when device state is set via sysfs")
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Mike Christie and committed by
Martin K. Petersen
eb97545d e0a2c28d

+1 -1
+1 -1
drivers/scsi/scsi_sysfs.c
··· 812 812 813 813 mutex_lock(&sdev->state_mutex); 814 814 if (sdev->sdev_state == SDEV_RUNNING && state == SDEV_RUNNING) { 815 - ret = count; 815 + ret = 0; 816 816 } else { 817 817 ret = scsi_device_set_state(sdev, state); 818 818 if (ret == 0 && state == SDEV_RUNNING)