From nobody Sun Feb 8 18:09:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133309; cv=none; d=zohomail.com; s=zohoarc; b=jw1Z0NJA1CpPzNhsSIpuIzm0Fj2iDxwx2P3uF2f1P2eo4eHn6792ZxE5oFV/3MsVEeapKBgPABfw0NDjpuIgBrrG0HHZe8Z9qrHxgI5vBU2WeJ086ENMWT8gego8euYezbRFt7U8RnhF3q4jWFRG0E9fOAEtnbfvE8CkAxoBpBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133309; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=sHnTHd5eOv4CE3kG7WFIppdUW+9gnxWfxjSmfY/2Ums=; b=WLev0E95qt2R/X/ltZX818ubeGkmXxDAY0VHddiG5WzozSPLv1aKr9L6DICAm5QIX0uzdeRH06WGlWATU25DYCBXcGnfPLq2+pmvJB2XsSYwADsCgtgK4Q5IqE61UPEcYqFjWTBE4cfmpxMX6vTKbCc6hbDxN4EeSXTZJCFnjEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133309104598.4674320237318; Tue, 3 Feb 2026 07:41:49 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 445F841A13; Tue, 3 Feb 2026 10:41:48 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id AF1D641C7D; Tue, 3 Feb 2026 10:40:10 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1A81E41986; Tue, 3 Feb 2026 10:40:05 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 95E0D41984 for ; Tue, 3 Feb 2026 10:40:04 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-n4WVGSy_Oxykm4TbcbNAbA-1; Tue, 03 Feb 2026 10:40:03 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 37A9B1800357 for ; Tue, 3 Feb 2026 15:40:02 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9383F1956048 for ; Tue, 3 Feb 2026 15:40:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sHnTHd5eOv4CE3kG7WFIppdUW+9gnxWfxjSmfY/2Ums=; b=ROOeSOfqlLxl8SV0w2BdGThkzdAGF4s4WaSpDkTl6jMrscWssdnedaqzl/ZZROEaI8e9Uu eRvuDedhfNTc8kmSmbVSgyj4VQO1EPEe2Jn1IWIsWO3kxzX96SzJwjbSD47mZEgI0O6ysx T9msFKZ6/ABgqStrfWtp4AQAvSd4vCU= X-MC-Unique: n4WVGSy_Oxykm4TbcbNAbA-1 X-Mimecast-MFC-AGG-ID: n4WVGSy_Oxykm4TbcbNAbA_1770133202 To: devel@lists.libvirt.org Subject: [PATCH 1/9] bhyve: Avoid memleak in bhyveParsePassthru() Date: Tue, 3 Feb 2026 16:39:49 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: DLlTA_GcWdxU0XL3pxB4jif-nlg7AkltzfrMiqyYZY8_1770133202 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7IN4WBBX3OTCNSCB5N5QDSI3FKW63KQZ X-Message-ID-Hash: 7IN4WBBX3OTCNSCB5N5QDSI3FKW63KQZ X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133310787158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The aim of bhyveParsePassthru() is to parse PCI address from bhyve command line. The PCI address might be of a form bus:slot:function or bus/slot/function. If the former isn't found the latter is parsed (both using g_strsplit()). But after the first call, g_strsplit() just returns a string list containing but the whole input duplicated. Therefore, calling plain g_free() is not enough, the array must be freed too. 6 bytes in 1 blocks are definitely lost in loss record 1 of 325 at 0x4863224: malloc (vg_replace_malloc.c:451) by 0x4EC6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4EE28D9: g_strsplit (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4011297: bhyveParsePassthru (bhyve_parse_command.c:699) by 0x4010082: bhyveParseBhyvePCIArg (bhyve_parse_command.c:800) by 0x400EE14: bhyveParseBhyveCommandLine (bhyve_parse_command.c:862) by 0x400DF9C: bhyveParseCommandLineString (bhyve_parse_command.c:1058) by 0x4008CA0: testCompareXMLToArgvFiles (bhyveargv2xmltest.c:39) by 0x4008B29: testCompareXMLToArgvHelper (bhyveargv2xmltest.c:105) by 0x4009288: virTestRun (testutils.c:143) by 0x40085AC: mymain (bhyveargv2xmltest.c:164) by 0x400B582: virTestMain (testutils.c:913) Signed-off-by: Michal Privoznik --- src/bhyve/bhyve_parse_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index 8b405206bd..3d9a6f3964 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -701,7 +701,7 @@ bhyveParsePassthru(virDomainDef *def G_GNUC_UNUSED, goto error; } if (g_str_equal(addr, *params)) { - g_free(params); + g_strfreev(params); if (!(params =3D g_strsplit(addr, "/", -1))) { virReportError(VIR_ERR_OPERATION_FAILED, _("Failed to parse PC= I address %1$s"), addr); goto error; --=20 2.52.0