From nobody Sat Feb 7 10:01:18 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; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1744638794409963.8544489925365; Mon, 14 Apr 2025 06:53:14 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 82ABD1644; Mon, 14 Apr 2025 09:53:13 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1F8301905; Mon, 14 Apr 2025 09:52:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C5F9BE3E; Mon, 14 Apr 2025 09:52:40 -0400 (EDT) Received: from air.basealt.ru (air.basealt.ru [193.43.8.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 38EF5E31 for ; Mon, 14 Apr 2025 09:52:40 -0400 (EDT) Received: from kuznetsovam-nb.office.basealt.ru (unknown [193.43.10.250]) (Authenticated sender: kuznetsovam) by air.basealt.ru (Postfix) with ESMTPSA id 94C61233A0; Mon, 14 Apr 2025 16:52:38 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 From: Alexander Kuznetsov To: pkrempa@redhat.com, devel@lists.libvirt.org Subject: [PATCH v2 1/1] nwfilter: Avoid possible double free in virNWFilterInstReset() Date: Mon, 14 Apr 2025 16:51:34 +0300 Message-ID: <20250414135227.37699-2-kuznetsovam@altlinux.org> X-Mailer: git-send-email 2.42.4 In-Reply-To: <20250414135227.37699-1-kuznetsovam@altlinux.org> References: <20250414135227.37699-1-kuznetsovam@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YM3EV2XMOE7QOKVITU7NRGZPGMV44IBR X-Message-ID-Hash: YM3EV2XMOE7QOKVITU7NRGZPGMV44IBR X-MailFrom: kuznetsovam@altlinux.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: nickel@altlinux.org, egori@altlinux.org X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZM-MESSAGEID: 1744638795643019100 Content-Type: text/plain; charset="utf-8" virNWFilterInstReset() may be called multiple times, leading to a double g_= free() Replace plain g_free() with g_clear_pointer() to prevent this Found by Linux Verification Center (linuxtesting.org) with Svace. Reported-by: Dmitry Fedin Signed-off-by: Alexander Kuznetsov Reviewed-by: Michal Privoznik --- src/nwfilter/nwfilter_gentech_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index f7a909bdc0..7462b84f88 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -203,12 +203,12 @@ virNWFilterInstReset(virNWFilterInst *inst) =20 for (i =3D 0; i < inst->nfilters; i++) virNWFilterObjUnlock(inst->filters[i]); - g_free(inst->filters); + g_clear_pointer(inst->filters, g_free); inst->nfilters =3D 0; =20 for (i =3D 0; i < inst->nrules; i++) virNWFilterRuleInstFree(inst->rules[i]); - g_free(inst->rules); + g_clear_pointer(inst->rules, g_free); inst->nrules =3D 0; } =20 --=20 2.42.4