Subject: [PATCH 10/18] Endian fix an assertion in usb-msd

From: Gerd Hoffmann <[email-masked]>
Date: Thu, 16 Aug 2012 11:39:12 +0200

RH-Author: Gerd Hoffmann <[email-masked]>
Message-id: <[email-masked]>
Patchwork-id: 40923
O-Subject: [RHEL-6.4 qemu-kvm PATCH 10/18] Endian fix an assertion in usb-msd
Bugzilla: 805172
RH-Acked-by: Paolo Bonzini <[email-masked]>
RH-Acked-by: Hans de Goede <[email-masked]>
RH-Acked-by: Laszlo Ersek <[email-masked]>

This fixes a broken endian assumption in an assertion in usb-msd.

Cc: Gerd Hoffman <[email-masked]>

Signed-off-by: Benjamin Herrenschmidt <[email-masked]>
Signed-off-by: David Gibson <[email-masked]>
Signed-off-by: Gerd Hoffmann <[email-masked]>
(cherry picked from commit e2854bf3239f57d160cfe5230033110c0c0d2837)

Conflicts:

	hw/usb-msd.c
---
 hw/usb-msd.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Signed-off-by: Michal Novotny <[email-masked]>
---
 hw/usb-msd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index d04b97f..8a8ced4 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -201,9 +201,9 @@ static void usb_msd_send_status(MSDState *s, USBPacket *p)
     int len;
 
     DPRINTF("Command status %d tag 0x%x, len %zd\n",
-            s->csw.status, s->csw.tag, p->len);
+            s->csw.status, le32_to_cpu(s->csw.tag), p->iov.size);
 
-    assert(s->csw.sig == 0x53425355);
+    assert(s->csw.sig == cpu_to_le32(0x53425355));
     len = MIN(sizeof(s->csw), p->len);
     memcpy(p->data, &s->csw, len);
     memset(&s->csw, 0, sizeof(s->csw));
@@ -240,7 +240,7 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, int32_t
 
     s->csw.sig = cpu_to_le32(0x53425355);
     s->csw.tag = cpu_to_le32(req->tag);
-    s->csw.residue = s->residue;
+    s->csw.residue = cpu_to_le32(s->residue);
     s->csw.status = status != 0;
 
     if (s->packet) {
-- 
1.7.11.4