From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UN96v-0007kB-7D for qemu-devel@nongnu.org; Tue, 02 Apr 2013 17:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UN96t-0000CW-HG for qemu-devel@nongnu.org; Tue, 02 Apr 2013 17:51:21 -0400 Sender: fluxion From: Michael Roth Date: Tue, 2 Apr 2013 16:45:19 -0500 Message-Id: <1364939142-30066-15-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1364939142-30066-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1364939142-30066-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 14/37] scsi-disk: do not complete canceled UNMAP requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Paolo Bonzini 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 Tested-by: Stefan Priebe Signed-off-by: Paolo Bonzini (cherry picked from commit d0242eadc5bba4f3abe34bc5d536bbfb81aa9891) Signed-off-by: Michael Roth --- hw/scsi-disk.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 6bc739d..c9c983a 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -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)) { @@ -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); } -- 1.7.9.5