aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-03-06 11:24:12 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2021-03-06 11:42:56 +0100
commit9738c657208800298a7d68272b861fb2dc49fee1 (patch)
treed1f27a5bac46be1e449b2d82621f911fa93dfee6 /hw
parentdb66a15cb80f09da24a5311a3f3b8f0c1835bf71 (diff)
downloadqemu-9738c657208800298a7d68272b861fb2dc49fee1.zip
qemu-9738c657208800298a7d68272b861fb2dc49fee1.tar.gz
qemu-9738c657208800298a7d68272b861fb2dc49fee1.tar.bz2
scsi-generic: do not snoop the output of failed commands
If a READ CAPACITY command would fail, for example s->qdev.blocksize would be set to zero and cause a division by zero on the next use. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/scsi/scsi-generic.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index cf7e11c..f9fd2cc 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -288,7 +288,10 @@ static void scsi_read_complete(void * opaque, int ret)
}
}
- if (len == 0) {
+ if (r->io_header.host_status != SCSI_HOST_OK ||
+ (r->io_header.driver_status & SG_ERR_DRIVER_TIMEOUT) ||
+ r->io_header.status != GOOD ||
+ len == 0) {
scsi_command_complete_noio(r, 0);
goto done;
}