Skip to content

Commit

Permalink
scsi-generic: do not snoop the output of failed commands
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bonzini committed Mar 6, 2021
1 parent db66a15 commit 9738c65
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hw/scsi/scsi-generic.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9738c65

Please sign in to comment.