[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 24/24] usb storage: fix status reporting
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 24/24] usb storage: fix status reporting |
Date: |
Thu, 9 Dec 2010 13:30:27 +0100 |
Change usb_msd_send_status() to take a pointer to the status packet
instead of writing the status to s->usb_buf which might not point
to the correct location.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb-msd.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 7b8189f..28c12dd 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -196,15 +196,18 @@ static void usb_msd_copy_data(MSDState *s)
}
}
-static void usb_msd_send_status(MSDState *s)
+static void usb_msd_send_status(MSDState *s, USBPacket *p)
{
struct usb_msd_csw csw;
+ int len;
csw.sig = cpu_to_le32(0x53425355);
csw.tag = cpu_to_le32(s->tag);
csw.residue = s->residue;
csw.status = s->result;
- memcpy(s->usb_buf, &csw, 13);
+
+ len = MIN(sizeof(csw), p->len);
+ memcpy(p->data, &csw, len);
}
static void usb_msd_command_complete(SCSIBus *bus, int reason, uint32_t tag,
@@ -224,7 +227,7 @@ static void usb_msd_command_complete(SCSIBus *bus, int
reason, uint32_t tag,
if (s->data_len == 0 && s->mode == USB_MSDM_DATAOUT) {
/* A deferred packet with no write data remaining must be
the status read packet. */
- usb_msd_send_status(s);
+ usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
} else {
if (s->data_len) {
@@ -425,9 +428,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
if (len < 13)
goto fail;
- s->usb_len = len;
- s->usb_buf = data;
- usb_msd_send_status(s);
+ usb_msd_send_status(s, p);
s->mode = USB_MSDM_CBW;
ret = 13;
break;
--
1.7.1
- [Qemu-devel] [PATCH 13/24] usb: move remote wakeup handling to common code, (continued)
- [Qemu-devel] [PATCH 13/24] usb: move remote wakeup handling to common code, Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 16/24] usb: add usb_wakeup() + wakeup callback to port ops, Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 20/24] usb: add attach callback, Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 17/24] usb: uhci: remote wakeup support., Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 18/24] usb: hid: remote wakeup support., Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 15/24] usb: rework attach/detach workflow, Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 23/24] usb storage: high speed support, Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 21/24] usb: add usb_desc_attach, Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 19/24] usb: add speed mask to ports, Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 22/24] usb: add device qualifier support, Gerd Hoffmann, 2010/12/09
- [Qemu-devel] [PATCH 24/24] usb storage: fix status reporting,
Gerd Hoffmann <=