[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/6] scsi: fix segfault with 0-byte disk
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 4/6] scsi: fix segfault with 0-byte disk |
Date: |
Tue, 22 Jan 2013 15:19:54 +0100 |
When a 0-sized disk is found, READ CAPACITY will return a
LUN NOT READY error. However, because it returns -1 instead
of zero, the HBA will call scsi_req_continue. This will
typically cause a segmentation fault or an assertion failure.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi-disk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index f8d7ef3..658e315 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1682,7 +1682,7 @@ static int32_t scsi_disk_emulate_command(SCSIRequest
*req, uint8_t *buf)
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
if (!nb_sectors) {
scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY));
- return -1;
+ return 0;
}
if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) {
goto illegal_request;
@@ -1751,7 +1751,7 @@ static int32_t scsi_disk_emulate_command(SCSIRequest
*req, uint8_t *buf)
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
if (!nb_sectors) {
scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY));
- return -1;
+ return 0;
}
if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) {
goto illegal_request;
--
1.8.1
- [Qemu-devel] [PULL 1.4 0/6] Pending SCSI patches for 1.4, Paolo Bonzini, 2013/01/22
- [Qemu-devel] [PATCH 1/6] iscsi: add iscsi_create support, Paolo Bonzini, 2013/01/22
- [Qemu-devel] [PATCH 2/6] iscsi: partly avoid iovec linearization in iscsi_aio_writev, Paolo Bonzini, 2013/01/22
- [Qemu-devel] [PATCH 4/6] scsi: fix segfault with 0-byte disk,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 5/6] lsi: use qbus_reset_all to reset SCSI bus, Paolo Bonzini, 2013/01/22
- [Qemu-devel] [PATCH 3/6] iscsi: add support for iSCSI NOPs [v2], Paolo Bonzini, 2013/01/22
- [Qemu-devel] [PATCH 6/6] scsi: Drop useless null test in scsi_unit_attention(), Paolo Bonzini, 2013/01/22