From: Hannes Reinecke Date: Tue, 22 Jun 2021 09:11:53 +0000 (+0200) Subject: scsi: virtio_scsi: Do not overwrite SCSI status X-Git-Tag: accepted/tizen/unified/20230118.172025~6832^2~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c43ddbf97f46b93727718408d60a47ce8c08f30c;p=platform%2Fkernel%2Flinux-rpi.git 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 Tested-by: Jiri Slaby Signed-off-by: Hannes Reinecke Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index fd69a03..ad78bf6 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);