From nobody Mon Sep 14 04:47:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788978364; cv=none; d=zohomail.com; s=zohoarc; b=eLfgk7tIAhqen+3NNOsRjLtV2r7dVzxDMkbCJg84sK5Hb3cG6N6v8/LWhy+oqmXRAxPoStqmLhnuZ3gKj/8J/2z+QzAcdQQwyFiyGGQf3WDNBO4gC1gRRyl63HQPZW4/lVbLf4FyxenYaJKEI0t0KYGq+3ihu4F9iLxZeF4PoKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788978364; h=Content-Transfer-Encoding:Cc:Cc: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:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=ME5oLkh1O7XtIGVRXrog3Zaqb1vLvTpnLceZlzAicaA=; b=iWGYWS6Px0TmC0V+gRQ5jIv1ocCba0SkBSovCCeT1DNXgiLOzJEO4kqzWIITAgEu5Esd3LxPS/tEnnPEFB2x6UiSwQyYlbkQVwnBxNki5uZ0pUSbry4pUYxtfONScMxSHSMeP7TD5OM76zXinibUUTNnGy9AgE7lF+3F5v4sfJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 178897836463652.98456728303813; Wed, 9 Sep 2026 11:26:04 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1DDEA3FA6C; Wed, 9 Sep 2026 14:26:02 -0400 (EDT) Received: from [172.19.199.13] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id CC5803FCA9 for ; Wed, 9 Sep 2026 14:23:52 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 22A2E3F2EF; Wed, 9 Sep 2026 14:23:31 -0400 (EDT) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (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 DEE523F34A for ; Wed, 9 Sep 2026 14:23:29 -0400 (EDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-c29432715d2so77644566b.2 for ; Wed, 09 Sep 2026 11:23:29 -0700 (PDT) Received: from tulp.my.domain (2001-1c02-1a15-3000-ee82-4536-a8f2-9e22.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:ee82:4536:a8f2:9e22]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c260d03644bsm813339866b.6.2026.09.09.11.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 11:23:27 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788978209; x=1789583009; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ME5oLkh1O7XtIGVRXrog3Zaqb1vLvTpnLceZlzAicaA=; b=hTJ1b0LAnXB8iw12Ccsf7GCDW7ClC4E6fJXhL0oAY7lf8iKob0DsMeVZ/mgvzl24bL x05tLkwGDsbXWXKrSL4EeFwcO7GlRyjV/89OHeAvGU2qtcPNFdgc5oy7MTiQ8FEhEJFS 0uSD1+TuJB5ksCgnqZdYB9h5Qa/4mTGMiUm17GO2sTWp+Y6eePkncMgbCgPO7C5BMy67 q5LeR13cy6i9A/xc42ZIVUIQTZDrix9sDxWfo8oCYT+Pr1FP7Tn8WjS45AAKnEDBAmc9 W53VR2/JcoKDKJlhXGPsoFwPQQMBVYY5o9GUE5b/gSKXSLSDYxVE9JEBAEuAvx7RfzKU qSLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788978209; x=1789583009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ME5oLkh1O7XtIGVRXrog3Zaqb1vLvTpnLceZlzAicaA=; b=YOE7KwgXk2eVtNLLIlm0E8k+ufFwBjEHPuuWH4p/fBNAiTDLFxaC8BXDp+ZOszhPv8 7eqlqPy9CVs3pg6aub7N2CE/S39zlPBXQWDGNwFu/TLyjIRmwpjjebjBav5YjKsJFXba rR0m204Z/eneTLtgAMoqE9Uqy6fhXrUruwInH7IemEEzO1PNsTLugSCvCpe1zxpEBUp3 77i1if+Ifi0DzJMvbHpOfo5ZCu3tix/bq9nhc/Eos9WTwLDEhBolFlasel3uqZsT0u4f QF5Y2Clac1Hn2Fhkhe6c1vFsT9oMaZWh5qwbR4B0Sn2A3vJAb6XRBfnLS2YPPQsWI5n4 5y2w== X-Gm-Message-State: AFuF++moyXfTRfoEld7Y2b6B95a0oxidnZfOeq2qucJJtK2YZHvcu0HZ vei5FVFrvu+BNY6QCKqr/uvqNC9mDBxXitDv22c9UT0uQ+GP2lKuMaoInygWDaXg X-Gm-Gg: AYBFou2PsN5JIoWOXZ/bwyeDbUVR1SazWHR0x7sDa66Uq8w627v40NRAdqyDPLXNq5Y ZSNrisfCl2JoLDAgunxzHDan8Y96pt/98E4ZBgxTMhyE5aSMyqJs8GIBpeKE17AHbuvFOqv0910 bPcKVy6nTeMh6jodd6FbJx3di/YGj32EUaqIx7Dkl9e8nxTH04UOnc8jqEGOkem0rFcVAPgad7Z tGue46By3oAYyTx3d43nSZDQ0kv0zTAeCAsabF+rQ5HCLxgUECDexK2ivf7Rfo6Wv0J3DhaTy22 qPVCAOS2wTotf/pVkrecpuNSLp0qNrap14XO6y8j8QsVPRsCX41VfAFbyrOG0leETwZ60+iRAbx iYwJ8l/fH6ThLAoZubbVYP5fedIyWJHbYyyTu9dJsmfaZCXMvdYk2D1N/ku2vZvYegc/nVBp44R 7BZ2bWjGAhml8RV/KVFFE39K4cb+1O45IOh94mOEOQUtnGkbrw6qLrHSrWTUooCgbHYVGckN6K7 Ke34SRx2UFSvE3jHg+jldXgxnUB/nUqG0m2tQsHOmnPs5mOKO7kEtYJoEyoK719FF64OsINjvNV Ui5ET0h7Og== X-Received: by 2002:a17:907:da7:b0:c26:1691:b371 with SMTP id a640c23a62f3a-c261691ba35mr1488036566b.42.1788978208371; Wed, 09 Sep 2026 11:23:28 -0700 (PDT) From: Roman Bogorodskiy To: devel@lists.libvirt.org Subject: [PATCH 1/2] virnetdevtap: fix tap device leak on rename Date: Wed, 9 Sep 2026 20:22:23 +0200 Message-ID: <20260909182224.26239-2-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909182224.26239-1-bogorodskiy@gmail.com> References: <20260909182224.26239-1-bogorodskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PGM2V4YBPBKLXVYLYPXRRI6WUFYXWA7Z X-Message-ID-Hash: PGM2V4YBPBKLXVYLYPXRRI6WUFYXWA7Z X-MailFrom: bogorodskiy@gmail.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 CC: Roman Bogorodskiy 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: X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788978366076158500 Content-Type: text/plain; charset="utf-8" On FreeBSD, virNetDevTapCreate() creates a generic tap(4) device and then renames to a desired value (typically vnetN). However, it does not delete the tap(4) device on errors, so it leaks the device when rename fails. Fix by attempting to remove the device in "cleanup:" if it was created. It's also closed before that because FreeBSD will not delete an opened device. Error handling is slightly updated: - For the unsupported "tapfdSize > 1" case return immediately, nothing to clean there - Also return when device creation fails. We have to duplicate VIR_FORCE_CLOSE(), but then in "cleanup" we are sure that "ifr" is initialized. Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- src/util/virnetdevtap.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index e3a6209642..aa0907dd0c 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -334,11 +334,12 @@ int virNetDevTapCreate(char **ifname, int s; struct ifreq ifr; int ret =3D -1; + bool created =3D false; =20 if (tapfdSize > 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Multiqueue devices are not supported on this sys= tem")); - goto cleanup; + return -1; } =20 /* auto-generate an unused name for the new device (this @@ -357,9 +358,12 @@ int virNetDevTapCreate(char **ifname, if (ioctl(s, SIOCIFCREATE2, &ifr) < 0) { virReportSystemError(errno, "%s", _("Unable to create tap device")); - goto cleanup; + VIR_FORCE_CLOSE(s); + return -1; } =20 + created =3D true; + if (tapfd) { g_autofree char *dev_path =3D NULL; dev_path =3D g_strdup_printf("/dev/%s", ifr.ifr_name); @@ -378,6 +382,18 @@ int virNetDevTapCreate(char **ifname, =20 ret =3D 0; cleanup: + if (ret < 0 && created) { + virErrorPtr err; + + virErrorPreserveLast(&err); + + if (tapfd) + VIR_FORCE_CLOSE(*tapfd); + + ignore_value(virNetDevTapDelete(ifr.ifr_name, NULL)); + virErrorRestore(&err); + } + VIR_FORCE_CLOSE(s); =20 return ret; --=20 2.55.0 From nobody Mon Sep 14 04:47:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788978436; cv=none; d=zohomail.com; s=zohoarc; b=QRe6uk/2F9ffgJJ2t9Q5GiZUpPXlRUEOh+GmcCQr4NQy3bjZ8tWwGXvCzwqgE1P4/hCoJQAPNVwSkyrkEhYuNQWJArO3SOYCFUWwD4AxORqVuzHOPwkR2aNk3ARdd4/HyKFdbSl75ljEg1ZDPX5P8o0lsx52LW1tgTYUTi0QNq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788978436; h=Content-Transfer-Encoding:Cc:Cc: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:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=SE/IfHrT+BQURtX0WJaju1BPKbt1DpLHLpp0dzHlvBk=; b=nYF1lvSgjlF6yK4FbT4VOeHTkvComt5HQV23s4ux3eThwXURI2hRSMXavdV2p5YsDc+J1av+p3JXPRGfzHfi51T0KP45q2MomUlyzydCFk7Kd9f9ZRofdEiywHkiIce1Q3u9zgk+FAkbkNVdWmLXVtlxyN+3z9q11olonEEMjuw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1788978436183519.7057974128063; Wed, 9 Sep 2026 11:27:16 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 990413F950; Wed, 9 Sep 2026 14:27:14 -0400 (EDT) Received: from [172.19.199.13] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 506CC417EA for ; Wed, 9 Sep 2026 14:24:00 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C0B4F3F2F3; Wed, 9 Sep 2026 14:23:31 -0400 (EDT) Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (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 A21263F323 for ; Wed, 9 Sep 2026 14:23:30 -0400 (EDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-c259e5c22ffso711871266b.1 for ; Wed, 09 Sep 2026 11:23:30 -0700 (PDT) Received: from tulp.my.domain (2001-1c02-1a15-3000-ee82-4536-a8f2-9e22.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:ee82:4536:a8f2:9e22]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c260d03644bsm813339866b.6.2026.09.09.11.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 11:23:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788978209; x=1789583009; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SE/IfHrT+BQURtX0WJaju1BPKbt1DpLHLpp0dzHlvBk=; b=Xa+HM6RRxW5v984gbOZZ2ikV5At/VcpKDhh8dG1PQdAGCAZhbR06k+9395ubLVCe5g 3e3z6J/+IPYEJnED2mfAzHYwILk9l2JDZWr4frbf9hMMlmK31f138N3tiEuOuKIiZ+t7 aINQHkaKrrc/zhGA5Wmq3C5KRy/HmmjLlCdjMHKZ4XsRb0eb65SS/49tGQx9h7BBHvQL vt3H9JBd61caCyvjSoxASD4TSusXgo4ajA+4xsoQqP73nzuQsVuZkeZ7Jer/3Epx/gUf 8ZWyKqRq6waosSivntXc7WG12lyQJzIvmhVl7rQrXMAkfkvLCkiI+g1Z7EQezHi/Rug2 UwNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788978209; x=1789583009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SE/IfHrT+BQURtX0WJaju1BPKbt1DpLHLpp0dzHlvBk=; b=MNjbrRwMvkJgaHKj/jLoQNwNGPOIWNlX8eSKAkxQmAQR09MmV3MZ6nglOvfZI/B14z p9IlPc0A6yodStckvde4puIkyRMgFuTFL2aWtXzgjLIvYGvl61JyD/34Th/v6CH4F9Hb lwtfsEjLvotYOne7pkweeaFfa7h3JCr+16OKzmzllKyCaMedMtr/TN5bwqXdYIOiPVLc OaijNOcSU081rPozm/Pt306ZERa6aKL0yEMQ3VT/9gwMlOzhzzw/4ctVS9ea91knQx+D 6syORSBEvsHePuZFkTbGQIcex0PBpqbbg8to9QzovXgFD/GknL69HvS9RWm8FT1rmsKu youg== X-Gm-Message-State: AFuF++nLBtdO1IQorKk7V9kPIJiXLQlN/79LxsAGf7tThQuujwoJb8eh MK7iuJj7fx1SlXo2ZDTeBI5M7N8BcVOqjWLU/Nr61ieN5awnaGNQJlxDXdOD3Urk X-Gm-Gg: AYBFou2HigbpIHLDszPthTFyE/CWwVAaekG0yokSwktjNGh8C22QY7FJavxbpvt7CEf X6WK2KXxDtt9EKKGr2uGtUvgeZo635/28HWiMzV2KaLYSYhkUnRpwtKq3NHwTNclzdYdfFC7WMZ 1BpzIw9PVnf31L8VduPYRFcXpo1i0e2f4QhbPWtHb+kqCF3c95wNnPkyERJzB47+tDn28e/dI/a XFahSg5svGMl2Xhhh+kPU1WoIrACOseB/Mu8DCtUN4IhP1zEsuHRJOXegPtMMsdcdoIToVrUpy+ 179pwXJDMJFtXCjyZndlevTit4x+vOy6D7wY2fuH3GSWtNjADbCPi2NB++oREjbbWwjUYtDsOFn B9qeFfB/SaMnVXC7CzvziYilMP4iCYZIa6p9jXAsUAxE5zzjUnSWrq5oSzkS6SO4HMuNwuiiNYV c93rANZE5rWqrPgtt3GmKJk6sSI6+cWn6UoFydgOlc5c/6PM2PQa/+Ydl7L4DogommI61WXutic tKf1pMDB47zchqNYy64M1tCY2lItiQsDqT6jngTNpoXM+Pc6spfiXUaEkS9nAzSATFYiBZpayic AyKELob6SZZDqlFQRZ0y X-Received: by 2002:a17:907:3f07:b0:c25:6e17:9b4 with SMTP id a640c23a62f3a-c260cb56d02mr1401712366b.24.1788978208941; Wed, 09 Sep 2026 11:23:28 -0700 (PDT) From: Roman Bogorodskiy To: devel@lists.libvirt.org Subject: [PATCH 2/2] virnetdevtap: fix tap device leak in virNetDevTapCreateInBridgePort() Date: Wed, 9 Sep 2026 20:22:24 +0200 Message-ID: <20260909182224.26239-3-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909182224.26239-1-bogorodskiy@gmail.com> References: <20260909182224.26239-1-bogorodskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JUYYVC2IC6PO4DMUEFLCPWF42UMGRJ3L X-Message-ID-Hash: JUYYVC2IC6PO4DMUEFLCPWF42UMGRJ3L X-MailFrom: bogorodskiy@gmail.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 CC: Roman Bogorodskiy 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: X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788978436479158500 Content-Type: text/plain; charset="utf-8" On FreeBSD, virNetDevTapCreateInBridgePort() might leak a tap(4) device. Specifically, we're creating a tap(4) device with virNetDevTapCreate() early in the function. Then we are performing various operations, e.g. virNetDevSetMAC() and virNetDevTapAttachBridge(), and on errors jump to the 'error' cleanup label where we close the tap device. As tap(4) devices configured by libvirt on FreeBSD do not destroy themselves on closing, they leak on errors in this function. So make sure to add device removal to the error handling of this function. Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- src/util/virnetdevtap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index aa0907dd0c..6c228ff086 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -695,6 +695,16 @@ int virNetDevTapCreateInBridgePort(const char *brname, for (i =3D 0; i < tapfdSize && tapfd[i] >=3D 0; i++) VIR_FORCE_CLOSE(tapfd[i]); =20 +#if defined(VIR_NETDEV_TAP_REQUIRE_MANUAL_CLEANUP) + if (!(flags & VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING)) { + virErrorPtr err; + + virErrorPreserveLast(&err); + ignore_value(virNetDevTapDelete(*ifname, tunpath)); + virErrorRestore(&err); + } +#endif /* VIR_NETDEV_TAP_REQUIRE_MANUAL_CLEANUP */ + return -1; } =20 --=20 2.55.0