summaryrefslogtreecommitdiff
path: root/drivers/scsi/virtio_scsi.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2021-06-22 12:11:53 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2021-06-23 04:50:15 +0300
commitc43ddbf97f46b93727718408d60a47ce8c08f30c (patch)
tree78711da39b15de7eb5a5dddf81f0b96ba55572b6 /drivers/scsi/virtio_scsi.c
parent49da96d77938db21864dae6b7736b71e96c1d203 (diff)
downloadlinux-c43ddbf97f46b93727718408d60a47ce8c08f30c.tar.xz
scsi: virtio_scsi: Do not overwrite SCSI status
When a sense code is present we should not override the SAM status; the driver already sets it based on the response from the hypervisor. In addition we should only copy the sense buffer if one is actually provided by the hypervisor. Link: https://lore.kernel.org/r/20210622091153.29231-1-hare@suse.de Fixes: 464a00c9e0ad ("scsi: core: Kill DRIVER_SENSE") Tested-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/virtio_scsi.c')
-rw-r--r--drivers/scsi/virtio_scsi.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index fd69a03d6137..ad78bf631900 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -156,12 +156,11 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
WARN_ON(virtio32_to_cpu(vscsi->vdev, resp->sense_len) >
VIRTIO_SCSI_SENSE_SIZE);
- if (sc->sense_buffer) {
+ if (resp->sense_len) {
memcpy(sc->sense_buffer, resp->sense,
min_t(u32,
virtio32_to_cpu(vscsi->vdev, resp->sense_len),
VIRTIO_SCSI_SENSE_SIZE));
- set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
}
sc->scsi_done(sc);