From: Hannes Reinecke Date: Fri, 25 Mar 2022 18:41:52 +0100 Subject: scsi-generic: check for additional SG_IO status on completion Git-commit: 0000000000000000000000000000000000000000 References: bsc#1178049 SG_IO may return additional status in the 'status', 'driver_status', and 'host_status' fields. When either of these fields are set the command has not been executed normally, so we should not continue processing this command but rather return an error. scsi_read_complete() already checks for these errors, scsi_write_complete() does not. Signed-off-by: Hannes Reinecke Signed-off-by: Lin Ma Signed-off-by: Dario Faggioli --- hw/scsi/scsi-generic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index aa3ae417ac726e9decf7e678e25f..8eb65f5f81bd4e998966571a3741 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -397,7 +397,10 @@ static void scsi_write_complete(void * opaque, int ret) aio_context_acquire(blk_get_aio_context(s->conf.blk)); - if (ret || r->req.io_canceled) { + if (ret || r->req.io_canceled || + r->io_header.status != SCSI_HOST_OK || + (r->io_header.driver_status & SG_ERR_DRIVER_TIMEOUT) || + r->io_header.status != GOOD) { scsi_command_complete_noio(r, ret); goto done; }