Received: from eggs.gnu.org ([2001:4830:134:3::10]:44564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c45Fa-0008LK-K1 for qemu-devel@nongnu.org; Tue, 08 Nov 2016 07:11:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c45FV-0001TL-NO for qemu-devel@nongnu.org; Tue, 08 Nov 2016 07:11:38 -0500 Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]:35347) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c45FV-0001TE-HA for qemu-devel@nongnu.org; Tue, 08 Nov 2016 07:11:33 -0500 Received: by mail-it0-x244.google.com with SMTP id b123so10641264itb.2 for ; Tue, 08 Nov 2016 04:11:33 -0800 (PST) Message-ID: <5821c0f4.091c6b0a.e0c92.e811@mx.google.com> From: Li Qiang Date: Tue, 8 Nov 2016 04:11:10 -0800 Subject: [Qemu-devel] [PATCH] usb: ehci: fix memory leak in ehci_init_transfer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kraxel@redhat.com, qemu-devel@nongnu.org Cc: Li Qiang From: Li Qiang In ehci_init_transfer function, if the 'cpage' is bigger than 4, it doesn't free the 'p->sgl' once allocated previously thus leading a memory leak issue. This patch avoid this. Signed-off-by: Li Qiang --- hw/usb/hcd-ehci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index f4ece9a..7622a3a 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1190,6 +1190,7 @@ static int ehci_init_transfer(EHCIPacket *p) while (bytes > 0) { if (cpage > 4) { fprintf(stderr, "cpage out of range (%d)\n", cpage); + qemu_sglist_destroy(&p->sgl); return -1; } -- 1.8.3.1