usb: ehci: fix memory leak in ehci_process_itd
PATCH 1/1 usb: ehci: fix memory leak in ehci_process_itd
From: Li Qiang <[email protected]>
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 doesn't be freed thus leading a memory leak issue. This patch avoid this.
--- hw/usb/hcd-ehci.c | 1 + 1 file changed, 1 insertion(+)
hw/usb/hcd-ehci.c +1 -0
@@ -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 );
Signature · 1 line
1.8.3.1
Ping!
2016-09-19 10:48 GMT+08:00 Li Qiang <[email protected]>:
Quoted 28 lines
From: Li Qiang <[email protected]>
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 doesn't be freed thus leading a memory leak issue. This patch avoid this.
Signed-off-by Li Qiang <[email protected]>--- hw/usb/hcd-ehci.c | 1 + 1 file changed, 1 insertion(+)hw/usb/hcd-ehci.c +1
-1@@ -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 ); --1.8.3.1
Quoted 5 lines · Li Qiang
From: Li Qiang <[email protected]>
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 doesn't be freed thus leading a memory
s/doesn't be/is not/
Quoted 13 lines
leak issue. This patch avoid this.
Signed-off-by Li Qiang <[email protected]>--- hw/usb/hcd-ehci.c | 1 + 1 file changed, 1 insertion(+)hw/usb/hcd-ehci.c +0
-0
hw/usb/hcd-ehci.c static int ehci_process_itd(EHCIState *ehci, · line 1432
Quoted 7 lines
hw/usb/hcd-ehci.c +1
-0@@ -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 );
Looks right to me.
Michael Tokarev
AppliedApplied to -trivial with comment fix, thanks!
/mjt