qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 5/6] scsi-disk: do not complete canceled UNMAP reque


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 5/6] scsi-disk: do not complete canceled UNMAP requests
Date: Tue, 5 Mar 2013 18:05:24 +0100

Canceled requests should never be completed, and doing that could cause
accesses to a NULL hba_private field.

Cc: address@hidden
Reported-by: Stefan Priebe <address@hidden>
Tested-by: Stefan Priebe <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
 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 d411586..6c0ddff 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1478,13 +1478,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)) {
@@ -1501,10 +1505,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.8.1.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]