thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
958e1b
From 8bb562cbc4c70ea2d338db0e86d99b0578a73955 Mon Sep 17 00:00:00 2001
240766
From: Fam Zheng <famz@redhat.com>
240766
Date: Fri, 4 Apr 2014 05:55:59 +0200
240766
Subject: [PATCH 04/12] block/iscsi: fix segfault if writesame fails
240766
240766
RH-Author: Fam Zheng <famz@redhat.com>
240766
Message-id: <1396590962-25815-5-git-send-email-famz@redhat.com>
240766
Patchwork-id: 58341
240766
O-Subject: [RHEL-7 0day qemu-kvm PATCH 4/7] block/iscsi: fix segfault if writesame fails
958e1b
Bugzilla: 1083413
240766
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
240766
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
240766
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
240766
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
240766
240766
From: Peter Lieven <pl@kamp.de>
240766
240766
commit fa6252b0 introduced a segfault because it tries
240766
to read iTask.task->sense after iTask.task has been
240766
freed.
240766
240766
Signed-off-by: Peter Lieven <pl@kamp.de>
240766
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
240766
(cherry picked from commit d9738fd2463f71530d8d92fbb52ebdd1d78074fc)
240766
Signed-off-by: Fam Zheng <famz@redhat.com>
240766
---
240766
 block/iscsi.c | 17 +++++++++--------
240766
 1 file changed, 9 insertions(+), 8 deletions(-)
240766
240766
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
240766
---
240766
 block/iscsi.c |   17 +++++++++--------
240766
 1 files changed, 9 insertions(+), 8 deletions(-)
240766
240766
diff --git a/block/iscsi.c b/block/iscsi.c
240766
index d3c8802..4a535e3 100644
240766
--- a/block/iscsi.c
240766
+++ b/block/iscsi.c
240766
@@ -1010,6 +1010,15 @@ retry:
240766
         qemu_coroutine_yield();
240766
     }
240766
 
240766
+    if (iTask.status == SCSI_STATUS_CHECK_CONDITION &&
240766
+        iTask.task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
240766
+        iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
240766
+        /* WRITE SAME is not supported by the target */
240766
+        iscsilun->has_write_same = false;
240766
+        scsi_free_scsi_task(iTask.task);
240766
+        return -ENOTSUP;
240766
+    }
240766
+
240766
     if (iTask.task != NULL) {
240766
         scsi_free_scsi_task(iTask.task);
240766
         iTask.task = NULL;
240766
@@ -1020,14 +1029,6 @@ retry:
240766
     }
240766
 
240766
     if (iTask.status != SCSI_STATUS_GOOD) {
240766
-        if (iTask.status == SCSI_STATUS_CHECK_CONDITION &&
240766
-            iTask.task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
240766
-            iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
240766
-            /* WRITE SAME is not supported by the target */
240766
-            iscsilun->has_write_same = false;
240766
-            return -ENOTSUP;
240766
-        }
240766
-
240766
         return -EIO;
240766
     }
240766
 
240766
-- 
240766
1.7.1
240766