]> git.proxmox.com Git - mirror_qemu.git/commitdiff
scsi-generic: do not snoop the output of failed commands
authorPaolo Bonzini <pbonzini@redhat.com>
Sat, 6 Mar 2021 10:24:12 +0000 (11:24 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 6 Mar 2021 10:42:56 +0000 (11:42 +0100)
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>
hw/scsi/scsi-generic.c

index cf7e11cf445b44affd8397ed974e5c2cc7db5c80..f9fd2ccfdd9411674697072631a105326ddebb07 100644 (file)
@@ -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;
     }