OpenCloudOS-Kernel/drivers/scsi/libsas
Jason Yan 621f6401fd scsi: libsas: fix length error in sas_smp_handler()
The return value of smp_execute_task_sg() is the untransferred residual,
but bsg_job_done() requires the length of payload received. This makes
SMP passthrough commands from userland by sg ioctl to libsas get a wrong
response. The userland tools such as smp_utils failed because of these
wrong responses:

~#smp_discover /dev/bsg/expander-2\:13
response too short, len=0
~#smp_discover /dev/bsg/expander-2\:134
response too short, len=0

Fix this by passing the actual received length to bsg_job_done(). And if
smp_execute_task_sg() returns 0, this means received length is exactly
the buffer length.

[mkp: typo]

Fixes: 651a013649 ("scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough")
Cc: <stable@vger.kernel.org> # v4.14+
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Reported-by: chenqilin <chenqilin2@huawei.com>
Tested-by: chenqilin <chenqilin2@huawei.com>
CC: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2017-12-11 21:45:34 -05:00
..
Kconfig scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough 2017-08-29 21:51:45 -04:00
Makefile Merge branch 'trivial' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2011-03-20 18:14:55 -07:00
sas_ata.c scsi: libsas: Annotate fall-through in a switch statement 2017-08-25 17:08:08 -04:00
sas_discover.c libsas: Fix Kernel Crash in smp_execute_task 2015-03-06 20:51:29 -08:00
sas_dump.c scsi: libsas: kill useless ha_event and do some cleanup 2017-09-15 21:32:58 -04:00
sas_dump.h scsi: libsas: kill useless ha_event and do some cleanup 2017-09-15 21:32:58 -04:00
sas_event.c scsi: libsas: add event to defer list tail instead of head when draining 2017-09-15 21:38:30 -04:00
sas_expander.c scsi: libsas: fix length error in sas_smp_handler() 2017-12-11 21:45:34 -05:00
sas_host_smp.c scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough 2017-08-29 21:51:45 -04:00
sas_init.c SCSI misc on 20171114 2017-11-14 16:23:44 -08:00
sas_internal.h scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough 2017-08-29 21:51:45 -04:00
sas_phy.c [SCSI] libsas: suspend / resume support 2012-08-24 13:10:23 +04:00
sas_port.c [SCSI] sas: unify the pointlessly separated enums sas_dev_type and sas_device_type 2013-05-10 07:47:52 -07:00
sas_scsi_host.c scsi: sas: Convert timers to use timer_setup() 2017-11-01 11:43:47 -07:00
sas_task.c scsi: Add export.h for EXPORT_SYMBOL/THIS_MODULE as required 2011-10-31 19:31:23 -04:00