From nobody Mon Dec 9 06:16:00 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728985926528145.01039049314045; Tue, 15 Oct 2024 02:52:06 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 233A51376; Tue, 15 Oct 2024 05:52:05 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1AFF5136D; Tue, 15 Oct 2024 05:51:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F08131235; Tue, 15 Oct 2024 05:51:45 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 5A22E11DD for ; Tue, 15 Oct 2024 05:51:45 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-fdVbzS_8M1m20GHuIr2_sg-1; Tue, 15 Oct 2024 05:51:43 -0400 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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CBCD11955EAB for ; Tue, 15 Oct 2024 09:51:42 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.43.2.246]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 288191956056 for ; Tue, 15 Oct 2024 09:51:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: *** X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728985905; 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; bh=5vg3TMqQzWeQKHfFdcVu5v1aNjXKfRm/b9jzW00mtvE=; b=gzUro3+lOeTCmhU55zbOl6ASEwYQAeYSN2WWwMfXUfgp1fOZ09vWgEMvC5tKa3obRS3bmb t+S5YKL4nvtQi/fjRDe3hOsiuVxKKSXeY85YxrcvRxLKXuTUghFS4Urq0VYlIBLF3SiGGf b4gPOY22/b88RgUl1l/NWhjAtwjz3Ic= X-MC-Unique: fdVbzS_8M1m20GHuIr2_sg-1 From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH v2] lxc: fix variable storage order before call Date: Tue, 15 Oct 2024 11:51:38 +0200 Message-ID: <266bb501bc3f59c000295b3d4949c40d5ca4d158.1728985859.git.ajulis@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JU3JJVWKDMG233WVA6ECH4TEAFLHAJ4Q X-Message-ID-Hash: JU3JJVWKDMG233WVA6ECH4TEAFLHAJ4Q X-MailFrom: ajulis@redhat.com 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 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-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728985928270116600 Content-Type: text/plain; charset="utf-8"; x-default="true" virDomainConfNWFilterInstantiate() was called without updated net->ifname, it caused in some cases throwing error message. If function failed, change is reverted. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/658 Signed-off-by: Adam Julis Reviewed-by: Jiri Denemark --- src/lxc/lxc_process.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 205ab96ebb..0233d17f4e 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -271,6 +271,7 @@ virLXCProcessSetupInterfaceTap(virDomainDef *vm, { g_autofree char *parentVeth =3D NULL; g_autofree char *containerVeth =3D NULL; + g_autofree char *backupIfname =3D NULL; const virNetDevVPortProfile *vport =3D virDomainNetGetActualVirtPortPr= ofile(net); =20 VIR_DEBUG("calling vethCreate()"); @@ -315,14 +316,17 @@ virLXCProcessSetupInterfaceTap(virDomainDef *vm, return NULL; } =20 - if (net->filter && - virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net, false) <= 0) - return NULL; - - /* success is guaranteed, so update the interface object */ - g_free(net->ifname); + /* success almost guaranteed, next function needs updated net->ifname = */ + backupIfname =3D g_steal_pointer(net->ifname); net->ifname =3D g_steal_pointer(&parentVeth); =20 + if (net->filter && + virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net, false) <= 0) { + g_free(net->ifname); + net->ifname =3D g_steal_pointer(&backupIfname); + return NULL; + } + return g_steal_pointer(&containerVeth); } =20 --=20 2.45.2