From patchwork Tue Sep 17 19:44:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 275528 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 560F22C00DA for ; Wed, 18 Sep 2013 05:46:05 +1000 (EST) Received: from localhost ([::1]:43182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VM1Dk-0005YP-F1 for incoming@patchwork.ozlabs.org; Tue, 17 Sep 2013 15:46:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VM1D0-0005X9-OM for qemu-devel@nongnu.org; Tue, 17 Sep 2013 15:45:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VM1Cu-0000T9-Og for qemu-devel@nongnu.org; Tue, 17 Sep 2013 15:45:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VM1Cu-0000QL-H7 for qemu-devel@nongnu.org; Tue, 17 Sep 2013 15:45:08 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8HJj7b7018642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Sep 2013 15:45:07 -0400 Received: from localhost.localdomain.com (vpn1-5-216.ams2.redhat.com [10.36.5.216]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r8HJj3a6027648; Tue, 17 Sep 2013 15:45:06 -0400 From: Hans de Goede To: Gerd Hoffmann Date: Tue, 17 Sep 2013 21:44:51 +0200 Message-Id: <1379447093-20181-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1379447093-20181-1-git-send-email-hdegoede@redhat.com> References: <1379447093-20181-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/5] xhci: Fix memory leak on xhci_disable_ep X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The USBPacket-s in the transfers need to be cleaned up so that the memory allocated by the iovec in there gets freed. Signed-off-by: Hans de Goede --- hw/usb/hcd-xhci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index c209228..18d2e13 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1364,6 +1364,7 @@ static TRBCCode xhci_disable_ep(XHCIState *xhci, unsigned int slotid, { XHCISlot *slot; XHCIEPContext *epctx; + int i; trace_usb_xhci_ep_disable(slotid, epid); assert(slotid >= 1 && slotid <= xhci->numslots); @@ -1384,6 +1385,10 @@ static TRBCCode xhci_disable_ep(XHCIState *xhci, unsigned int slotid, xhci_free_streams(epctx); } + for (i = 0; i < ARRAY_SIZE(epctx->transfers); i++) { + usb_packet_cleanup(&epctx->transfers[i].packet); + } + xhci_set_ep_state(xhci, epctx, NULL, EP_DISABLED); qemu_free_timer(epctx->kick_timer);