diff options
author | Peter Lieven <pl@kamp.de> | 2014-02-22 13:17:24 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-02-22 15:59:24 +0100 |
commit | d9738fd2463f71530d8d92fbb52ebdd1d78074fc (patch) | |
tree | 8b817a8da338ca119fd1270173d9dc3ee8480f12 /block | |
parent | 64cc22841e72d37d577416f5836155ecd0a9bfb6 (diff) | |
download | qemu-d9738fd2463f71530d8d92fbb52ebdd1d78074fc.zip qemu-d9738fd2463f71530d8d92fbb52ebdd1d78074fc.tar.gz qemu-d9738fd2463f71530d8d92fbb52ebdd1d78074fc.tar.bz2 |
block/iscsi: fix segfault if writesame fails
commit fa6252b0 introduced a segfault because it tries
to read iTask.task->sense after iTask.task has been
freed.
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/iscsi.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/block/iscsi.c b/block/iscsi.c index 4360cf1..0a15f53 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -836,6 +836,15 @@ retry: qemu_coroutine_yield(); } + if (iTask.status == SCSI_STATUS_CHECK_CONDITION && + iTask.task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && + iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { + /* WRITE SAME is not supported by the target */ + iscsilun->has_write_same = false; + scsi_free_scsi_task(iTask.task); + return -ENOTSUP; + } + if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; @@ -847,14 +856,6 @@ retry: } if (iTask.status != SCSI_STATUS_GOOD) { - if (iTask.status == SCSI_STATUS_CHECK_CONDITION && - iTask.task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST && - iTask.task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { - /* WRITE SAME is not supported by the target */ - iscsilun->has_write_same = false; - return -ENOTSUP; - } - return -EIO; } |