From nobody Tue May 7 06:27:44 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=1578626270; cv=none; d=zohomail.com; s=zohoarc; b=FU0LSZyLrcIksYxuP3fphGHeqNtn1lIq7J4To5Pz/Fr3fWQeSqHE/w3O67zwFmJOdgQ3Qh2tSXhxwbRzFh/rk8X3Gsllqq+p7YjUCyqHStwHJqdzlqzQW/SxEx0c8A03qVdTwoTBQT5ceM4KpBCg7kkJ5kN53QupGJUCUIytSKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578626270; 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=61rrQ/sNUSz63xm60jf19Medk3Z+fnxTiaoSzIy/q18=; b=nZd0xcGQ+xMvre6yE7gJqXS5RNDYVVVXZYjTp8Je1vDNnnHVh4MoIeNP8E8KHj12koljLFnsHALSOq4MjeJkefazqLzlaSaDZvVhycw3wPAS06H8wdgrRu3g6gQ+j71qNJnEY4Z4wkzfXDyKvuzu5olCThG4E2XGdnSCid6ZALA= 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 1578626270116384.5246834858449; Thu, 9 Jan 2020 19:17:50 -0800 (PST) Received: from localhost ([::1]:40010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipko0-0007Tp-KB for importer@patchew.org; Thu, 09 Jan 2020 22:17:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53394) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipknI-0006qY-V1 for qemu-devel@nongnu.org; Thu, 09 Jan 2020 22:17:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipknH-00088p-GD for qemu-devel@nongnu.org; Thu, 09 Jan 2020 22:17:04 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2673 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ipknH-0007Xw-34; Thu, 09 Jan 2020 22:17:03 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id AFEB6365904B72CFACFA; Fri, 10 Jan 2020 11:16:54 +0800 (CST) Received: from DESKTOP-9NTIQGG.china.huawei.com (10.173.221.136) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Fri, 10 Jan 2020 11:16:48 +0800 From: To: Subject: [PATCH] vl: Don't mismatch g_strsplit()/g_free() Date: Fri, 10 Jan 2020 11:16:18 +0800 Message-ID: <20200110031618.23332-1-pannengyuan@huawei.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.173.221.136] 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.190 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, Euler Robot , Pan Nengyuan , qemu-devel@nongnu.org, 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: Pan Nengyuan It's a mismatch between g_strsplit and g_free, it will cause a memory leak = as follow: [root@localhost]# ./aarch64-softmmu/qemu-system-aarch64 -accel help Accelerators supported in QEMU binary: tcg kvm =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D1207900=3D=3DERROR: LeakSanitizer: detected memory leaks Direct leak of 8 byte(s) in 2 object(s) allocated from: #0 0xfffd700231cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0xfffd6ec57163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0xfffd6ec724d7 in g_strndup (/lib64/libglib-2.0.so.0+0x724d7) #3 0xfffd6ec73d3f in g_strsplit (/lib64/libglib-2.0.so.0+0x73d3f) #4 0xaaab66be5077 in main /mnt/sdc/qemu-master/qemu-4.2.0-rc0/vl.c:3517 #5 0xfffd6e140b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #6 0xaaab66bf0f53 (./build/aarch64-softmmu/qemu-system-aarch64+0x8a0f5= 3) Direct leak of 2 byte(s) in 2 object(s) allocated from: #0 0xfffd700231cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0xfffd6ec57163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0xfffd6ec7243b in g_strdup (/lib64/libglib-2.0.so.0+0x7243b) #3 0xfffd6ec73e6f in g_strsplit (/lib64/libglib-2.0.so.0+0x73e6f) #4 0xaaab66be5077 in main /mnt/sdc/qemu-master/qemu-4.2.0-rc0/vl.c:3517 #5 0xfffd6e140b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #6 0xaaab66bf0f53 (./build/aarch64-softmmu/qemu-system-aarch64+0x8a0f5= 3) Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Reviewed-by: Laurent Vivier Reviewed-by: Marc-Andr=C3=A9 Lureau --- vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vl.c b/vl.c index 86474a55c9..2fa5cb3b9a 100644 --- a/vl.c +++ b/vl.c @@ -3476,7 +3476,7 @@ int main(int argc, char **argv, char **envp) gchar **optname =3D g_strsplit(typename, ACCEL_CLASS_SUFFI= X, 0); printf("%s\n", optname[0]); - g_free(optname); + g_strfreev(optname); } g_free(typename); } --=20 2.21.0.windows.1