From nobody Sun May 5 01:57:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1578654000; cv=none; d=zohomail.com; s=zohoarc; b=jkV0V5XxoefHYJ6mkx/43k7Bk2z2kHpGXTFFhnwLtV6ZF3kWFvPvLK9//bOW3RQEMUlcLOdChb15lP58pcIQ+bcnUjsFrdn8y9PBNIh5JF3WtG8NI5VoFPmYhKj3a8ynWv2IecJwgsn3A3/TUygj3rSPbTz3WuIBlQdK0a/fnyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578654000; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=9ee+AuN3FjVl1VBqVuljLA10pdc6w0c9O1xZz/FgwmE=; b=QiZC/u/4d/l2TiqPa34BM7VkuI5WluGQGnnUpT1PGtZk7cKG3fScUn9eGlTond6rQf96XElTy4MsDCWcM9bq049qVHvdKMK83Mft0HTvDwJaySE7DLCOTfE0+Lh1Bsx3218OASe4GFfEBiNDofb/ls98QfSGw0HHZ7+w+suod/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578654000047743.0920404320757; Fri, 10 Jan 2020 03:00:00 -0800 (PST) Received: from localhost ([::1]:44064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ips1G-0000cv-Gh for importer@patchew.org; Fri, 10 Jan 2020 05:59:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45697) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ips0e-0000Bj-1I for qemu-devel@nongnu.org; Fri, 10 Jan 2020 05:59:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ips0c-00041f-Lc for qemu-devel@nongnu.org; Fri, 10 Jan 2020 05:59:19 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:56936 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ips0c-0003YR-9s; Fri, 10 Jan 2020 05:59:18 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6905F66E5737D2D7369D; Fri, 10 Jan 2020 18:59:08 +0800 (CST) Received: from HGHY4C002233111.china.huawei.com (10.133.205.93) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Fri, 10 Jan 2020 18:59:00 +0800 From: To: , Subject: [PATCH] xhci: Fix memory leak in xhci_kick_epctx when poweroff GuestOS Date: Fri, 10 Jan 2020 18:58:55 +0800 Message-ID: <20200110105855.81144-1-kuhn.chenqun@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.133.205.93] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Chen Qun , pannengyuan@huawei.com, zhang.zhanghailiang@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Chen Qun start vm with libvirt, when GuestOS running, enter poweroff command using the xhci keyboard, then ASAN shows memory leak stack=EF=BC=9A Direct leak of 80 byte(s) in 5 object(s) allocated from: #0 0xfffd1e6431cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0xfffd1e107163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0xaaad39051367 in qemu_sglist_init /qemu/dma-helpers.c:43 #3 0xaaad3947c407 in pci_dma_sglist_init /qemu/include/hw/pci/pci.h:842 #4 0xaaad3947c407 in xhci_xfer_create_sgl /qemu/hw/usb/hcd-xhci.c:1446 #5 0xaaad3947c407 in xhci_setup_packet /qemu/hw/usb/hcd-xhci.c:1618 #6 0xaaad3948625f in xhci_submit /qemu/hw/usb/hcd-xhci.c:1827 #7 0xaaad3948625f in xhci_fire_transfer /qemu/hw/usb/hcd-xhci.c:1839 #8 0xaaad3948625f in xhci_kick_epctx /qemu/hw/usb/hcd-xhci.c:1991 #9 0xaaad3948f537 in xhci_doorbell_write /qemu/hw/usb/hcd-xhci.c:3158 #10 0xaaad38bcbfc7 in memory_region_write_accessor /qemu/memory.c:483 #11 0xaaad38bc654f in access_with_adjusted_size /qemu/memory.c:544 #12 0xaaad38bd1877 in memory_region_dispatch_write /qemu/memory.c:1482 #13 0xaaad38b1c77f in flatview_write_continue /qemu/exec.c:3167 #14 0xaaad38b1ca83 in flatview_write /qemu/exec.c:3207 #15 0xaaad38b268db in address_space_write /qemu/exec.c:3297 #16 0xaaad38bf909b in kvm_cpu_exec /qemu/accel/kvm/kvm-all.c:2383 #17 0xaaad38bb063f in qemu_kvm_cpu_thread_fn /qemu/cpus.c:1246 #18 0xaaad39821c93 in qemu_thread_start /qemu/util/qemu-thread-posix.c:= 519 #19 0xfffd1c8378bb (/lib64/libpthread.so.0+0x78bb) #20 0xfffd1c77616b (/lib64/libc.so.6+0xd616b) Reported-by: Euler Robot Signed-off-by: Chen Qun --- hw/usb/hcd-xhci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 80988bb305..0d3d96d05a 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2000,6 +2000,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) if (xfer !=3D NULL && xfer->running_retry) { DPRINTF("xhci: xfer nacked, stopping schedule\n"); epctx->retry =3D xfer; + xhci_xfer_unmap(xfer); break; } if (count++ > TRANSFER_LIMIT) { --=20 2.23.0