From nobody Sun Feb 8 18:49:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1612314438; cv=none; d=zohomail.com; s=zohoarc; b=EtArf+h3sSAnyyiZiKeISlftTOsQTauK8c4i+v2STx1XDg5MG5ej5A5Pb8zgG6BSuewMcgPvqrFi6Q+ZxZHKiBcrAbMvsh2MfeJY4FqY+wFgyv1j3jhUwKS8wOGLGZSDbwdvBUYuVSsQjDNb6EzMeF9sO9lZBBiioEPUuyrga8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612314438; h=Content-Type:Content-Transfer-Encoding:Cc: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=zX47cbwDX+33BdPnEq4S8S+tVeRXIjnbZC52EJeSJFI=; b=UdAzP7QtoO1G564aA8R8J2iIO8KfegJWz96EgwYNpzVEBWNDLEG13rbEBtbwzOBfwaxIXRRfu8ytkE1Z1XilHd+Rrz0PqasAlEDLmQU685vQAt+UhIYx0GRYiG6SAL2LjIKkGwwy9IJGbc+zl2+7i5XY3bUQJFL1iu50IBce0bs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612314438660986.189251734789; Tue, 2 Feb 2021 17:07:18 -0800 (PST) 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-268-dhIhDNHPNKGH_cijLFAUPg-1; Tue, 02 Feb 2021 20:07:15 -0500 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 539D2189DF57; Wed, 3 Feb 2021 01:07:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2BAB85D763; Wed, 3 Feb 2021 01:07:10 +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 DE5231809C8F; Wed, 3 Feb 2021 01:07:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11316ou2010352 for ; Tue, 2 Feb 2021 20:06:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 247622166B2D; Wed, 3 Feb 2021 01:06:50 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F4302166B2A for ; Wed, 3 Feb 2021 01:06:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0BFD2101042F for ; Wed, 3 Feb 2021 01:06:50 +0000 (UTC) Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-50-SyjrKiO9NkS-jco_4VTRTg-1; Tue, 02 Feb 2021 20:06:47 -0500 Received: by mail-qt1-f171.google.com with SMTP id l23so16432544qtq.13; Tue, 02 Feb 2021 17:06:47 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:6df1:6267:881f:cc79:a1f7]) by smtp.gmail.com with ESMTPSA id g6sm328813qtr.87.2021.02.02.17.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 17:06:46 -0800 (PST) X-MC-Unique: dhIhDNHPNKGH_cijLFAUPg-1 X-MC-Unique: SyjrKiO9NkS-jco_4VTRTg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zX47cbwDX+33BdPnEq4S8S+tVeRXIjnbZC52EJeSJFI=; b=K7NyaNayK2aTmrMvDJKJcoYaFrvwR6kVwJm+E2AldQAGlK06mecqAJl5fwlklELyrK wF/5xKq4PDaChETFjYZKroTuU+IO2XR+TVxIklP2dFn0R0hKr0YikDOvFuLxzlU1rXl2 59UEFAAOx7bb+d6tCVF6tUuvv0TB2WmZWI+KXaQsbNQgWLRyUvNVuqqZCmLTDMZ+Sc96 Dur69bMRfaBOUdVY2JqP4G8ym985zOvlHV5VIFcPV3RUNyB3YzT9SiyKRAPv8R/2Y9XV HSFv7fdXNvfV7MUpFWomh5QWcT7SKGnP3Ot5U4S6weWMCKNe1S0tMPINvVP7WvEinr88 OX7g== X-Gm-Message-State: AOAM530QLl2b9p9KxehF/hWjn2pr+/EHuHW0xxDDJCZB6Ew7foSBwkjq zYGtZjyNdf+RptW6mHqpI1WrVOAH3TU= X-Google-Smtp-Source: ABdhPJyE0Ef+5RWHpZbBWrpCXr9yN4TfEe1xytDPMTJPSCrHzJ9tSbEfUpOGrfavowPMtbnv1WK82Q== X-Received: by 2002:ac8:66c9:: with SMTP id m9mr534257qtp.43.1612314407057; Tue, 02 Feb 2021 17:06:47 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 06/10] libxl_driver.c: validate 'driverName' earlier in libxlNodeDeviceDetachFlags() Date: Tue, 2 Feb 2021 22:06:21 -0300 Message-Id: <20210203010625.2328911-7-danielhb413@gmail.com> In-Reply-To: <20210203010625.2328911-1-danielhb413@gmail.com> References: <20210203010625.2328911-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , =?UTF-8?q?J=C3=A1n=20Tomko?= 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The validation of 'driverName' does not depend on any other state and can be done right on the start of the function. We can fail earlier while avoiding a cleanup jump. Reviewed-by: J=C3=A1n Tomko Signed-off-by: Daniel Henrique Barboza --- src/libxl/libxl_driver.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 316a6c6bf5..eadacdfb76 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5791,6 +5791,12 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev, =20 virCheckFlags(0, -1); =20 + if (driverName && STRNEQ(driverName, "xen")) { + virReportError(VIR_ERR_INVALID_ARG, + _("unsupported driver name '%s'"), driverName); + return -1; + } + if (!(nodeconn =3D virGetConnectNodeDev())) goto cleanup; =20 @@ -5822,13 +5828,7 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev, if (!pci) goto cleanup; =20 - if (!driverName || STREQ(driverName, "xen")) { - virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN); - } else { - virReportError(VIR_ERR_INVALID_ARG, - _("unsupported driver name '%s'"), driverName); - goto cleanup; - } + virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN); =20 if (virHostdevPCINodeDeviceDetach(hostdev_mgr, pci) < 0) goto cleanup; --=20 2.26.2