OSDN Git Service

usb: ehci: fix memory leak in ehci_process_itd
authorLi Qiang <liqiang6-s@360.cn>
Mon, 19 Sep 2016 02:48:35 +0000 (19:48 -0700)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 8 Oct 2016 08:25:29 +0000 (11:25 +0300)
While processing isochronous transfer descriptors(iTD), if the page
select(PG) field value is out of bands it will return. In this
situation the ehci's sg list is not freed thus leading to a memory
leak issue. This patch avoid this.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/usb/hcd-ehci.c

index b093db7..f4ece9a 100644 (file)
@@ -1426,6 +1426,7 @@ static int ehci_process_itd(EHCIState *ehci,
             if (off + len > 4096) {
                 /* transfer crosses page border */
                 if (pg == 6) {
+                    qemu_sglist_destroy(&ehci->isgl);
                     return -1;  /* avoid page pg + 1 */
                 }
                 ptr2 = (itd->bufptr[pg + 1] & ITD_BUFPTR_MASK);