Skip to content

Commit

Permalink
scsi-disk: do not complete canceled UNMAP requests
Browse files Browse the repository at this point in the history
Canceled requests should never be completed, and doing that could cause
accesses to a NULL hba_private field.

Cc: qemu-stable@nongnu.org
Reported-by: Stefan Priebe <s.priebe@profihost.ag>
Tested-by: Stefan Priebe <s.priebe@profihost.ag>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit d0242ea)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
bonzini authored and mdroth committed Apr 2, 2013
1 parent f23ab03 commit 99b1f39
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions hw/scsi-disk.c
Expand Up @@ -1493,13 +1493,17 @@ static void scsi_unmap_complete(void *opaque, int ret)
uint32_t nb_sectors;

r->req.aiocb = NULL;
if (r->req.io_canceled) {
goto done;
}

if (ret < 0) {
if (scsi_handle_rw_error(r, -ret)) {
goto done;
}
}

if (data->count > 0 && !r->req.io_canceled) {
if (data->count > 0) {
sector_num = ldq_be_p(&data->inbuf[0]);
nb_sectors = ldl_be_p(&data->inbuf[8]) & 0xffffffffULL;
if (!check_lba_range(s, sector_num, nb_sectors)) {
Expand All @@ -1516,10 +1520,9 @@ static void scsi_unmap_complete(void *opaque, int ret)
return;
}

scsi_req_complete(&r->req, GOOD);

done:
if (data->count == 0) {
scsi_req_complete(&r->req, GOOD);
}
if (!r->req.io_canceled) {
scsi_req_unref(&r->req);
}
Expand Down

0 comments on commit 99b1f39

Please sign in to comment.