a19a21
From 6955223aa15ab6ea53322218ec03fb3dc2b776f8 Mon Sep 17 00:00:00 2001
a19a21
From: Jon Maloy <jmaloy@redhat.com>
a19a21
Date: Thu, 14 Jan 2021 00:07:05 -0500
a19a21
Subject: [PATCH 16/17] hw: ehci: check return value of 'usb_packet_map'
a19a21
a19a21
RH-Author: Jon Maloy <jmaloy@redhat.com>
a19a21
Message-id: <20210114000705.945169-2-jmaloy@redhat.com>
a19a21
Patchwork-id: 100634
a19a21
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/1] hw: ehci: check return value of 'usb_packet_map'
a19a21
Bugzilla: 1898628
a19a21
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
a19a21
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
a19a21
RH-Acked-by: Thomas Huth <thuth@redhat.com>
a19a21
a19a21
From: Li Qiang <liq3ea@163.com>
a19a21
a19a21
If 'usb_packet_map' fails, we should stop to process the usb
a19a21
request.
a19a21
a19a21
Signed-off-by: Li Qiang <liq3ea@163.com>
a19a21
Message-Id: <20200812161727.29412-1-liq3ea@163.com>
a19a21
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
a19a21
a19a21
(cherry picked from commit 2fdb42d840400d58f2e706ecca82c142b97bcbd6)
a19a21
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
a19a21
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a19a21
---
a19a21
 hw/usb/hcd-ehci.c | 10 ++++++++--
a19a21
 1 file changed, 8 insertions(+), 2 deletions(-)
a19a21
a19a21
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
a19a21
index 56ab2f457f4..024b1ed6b67 100644
a19a21
--- a/hw/usb/hcd-ehci.c
a19a21
+++ b/hw/usb/hcd-ehci.c
a19a21
@@ -1374,7 +1374,10 @@ static int ehci_execute(EHCIPacket *p, const char *action)
a19a21
         spd = (p->pid == USB_TOKEN_IN && NLPTR_TBIT(p->qtd.altnext) == 0);
a19a21
         usb_packet_setup(&p->packet, p->pid, ep, 0, p->qtdaddr, spd,
a19a21
                          (p->qtd.token & QTD_TOKEN_IOC) != 0);
a19a21
-        usb_packet_map(&p->packet, &p->sgl);
a19a21
+        if (usb_packet_map(&p->packet, &p->sgl)) {
a19a21
+            qemu_sglist_destroy(&p->sgl);
a19a21
+            return -1;
a19a21
+        }
a19a21
         p->async = EHCI_ASYNC_INITIALIZED;
a19a21
     }
a19a21
 
a19a21
@@ -1453,7 +1456,10 @@ static int ehci_process_itd(EHCIState *ehci,
a19a21
             if (ep && ep->type == USB_ENDPOINT_XFER_ISOC) {
a19a21
                 usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false,
a19a21
                                  (itd->transact[i] & ITD_XACT_IOC) != 0);
a19a21
-                usb_packet_map(&ehci->ipacket, &ehci->isgl);
a19a21
+                if (usb_packet_map(&ehci->ipacket, &ehci->isgl)) {
a19a21
+                    qemu_sglist_destroy(&ehci->isgl);
a19a21
+                    return -1;
a19a21
+                }
a19a21
                 usb_handle_packet(dev, &ehci->ipacket);
a19a21
                 usb_packet_unmap(&ehci->ipacket, &ehci->isgl);
a19a21
             } else {
a19a21
-- 
a19a21
2.27.0
a19a21