From nobody Tue Feb 10 12:57:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621624303; cv=none; d=zohomail.com; s=zohoarc; b=l7IAMQO4jIzjtEmXSjVIlB3EbOt1H0vqsTjtrwLMqgeutFeUxaKv0qSrJvauSRcR5Pgy5gy33O3lLchLgjt0Ujvz+UZzMgP53x6AumpHEA2GpJzVdRl+eum9vR871i0tkaR3w2UrwOU5acJdwOWWxVhXh1uTRqFj2rJIfMSR+lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621624303; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L+zSOjHjjvRwam3IeZ+HiX6n8iV85KSvbi0ceTU3MtI=; b=LJXfLXIuDuOeKkWeg7MsrQbtDhkLUdzA/oSjfBL57E5nTPiVspl9Twb/fmVj7ZMcU8FmjTRYQT5o/kRJU0z0TRp9lwGdeRYGR2Y8j5Zs/GDiQIx87+0mnv5aWyx/of+RMHzSAzIgzQb79Sjn3GyJ8Pp+7F+2WldetN2zmkXaLJ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621624303102644.0120751944843; Fri, 21 May 2021 12:11:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-sIARpLv2MSS78zrdJMco7A-1; Fri, 21 May 2021 15:11:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E69AE801107; Fri, 21 May 2021 19:11:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9E235D6DC; Fri, 21 May 2021 19:11:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 93E8844A6C; Fri, 21 May 2021 19:11:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LJBMRo005491 for ; Fri, 21 May 2021 15:11:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CC0946; Fri, 21 May 2021 19:11:22 +0000 (UTC) Received: from vhost2.router.laine.org (ovpn-113-185.phx2.redhat.com [10.3.113.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F1CD19C45 for ; Fri, 21 May 2021 19:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621624302; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=L+zSOjHjjvRwam3IeZ+HiX6n8iV85KSvbi0ceTU3MtI=; b=CNKriUczaRK7wpS22yg/4HL809IyYEyJFALXgKs0otONq8wvQDRNKK2FijJv3nH5Nbk6XZ HW9ogynG81Ayv789T/R6uTiRGMc0YX3sgQ91E86WMgNkmgq+inwzKpHtnAdB1wuPYZaByO 3ASEjLgyMRL3sEukVOwJXcJBSFx8qls= X-MC-Unique: sIARpLv2MSS78zrdJMco7A-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] qemu_hotplug.c: don't skip cleanup on failures of qemuDomainAttachNetDevice Date: Fri, 21 May 2021 15:11:17 -0400 Message-Id: <20210521191120.936899-2-laine@redhat.com> In-Reply-To: <20210521191120.936899-1-laine@redhat.com> References: <20210521191120.936899-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We have many places where the earliest error returns from a function skip any cleanup label at the bottom (the assumption being that it is so early in the function that there isn't yet anything that needs to be explicitly undone on failure). But in general it is a bad sign if there are any direct "return" statements in a function at any time after there has been a "goto cleanup" - that indicates someone thought that an earlier point in the code had done something needing cleanup, so we shouldn't be skipping it. There were two occurences of a "return -1" after "goto cleanup" in qemuDomainAttachDeviceNet(). The first of these has been around for a very long time (since 2013) and my assumption is that the earlier "goto cleanup" didn't exist at that time (so it was proper), and when the code further up in the function was added, the this return -1 was missed. The second was added during a mass change to check the return from qemuInterfacePrepareSlirp() in several places (commit 99a1cfc43889c6d); in this case it was erroneous from the start. Change both of these "return -1"s to "goto cleanup". Since we already have code paths earlier in the function that goto cleanup, this should not cause any new problem. Signed-off-by: Laine Stump --- src/qemu/qemu_hotplug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index c6f275e11d..244cf65c87 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1212,7 +1212,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, =20 /* final validation now that we have full info on the type */ if (qemuDomainValidateActualNetDef(net, priv->qemuCaps) < 0) - return -1; + goto cleanup; =20 actualType =3D virDomainNetGetActualType(net); =20 @@ -1330,7 +1330,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, int rv =3D qemuInterfacePrepareSlirp(driver, net, &slirp); =20 if (rv =3D=3D -1) - return -1; + goto cleanup; if (rv =3D=3D 0) break; =20 --=20 2.31.1