From nobody Thu May 9 02:15:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1634558952; cv=none; d=zohomail.com; s=zohoarc; b=Yxz0YntGt4DochYK3hcX9TF26qGdJ7TZirrNiHzQXfvWbTBMS1S5f+4H7UH9xAOuCAsMMuOsSvrBEzZjGFlZI3hylt2YIH33laINmFkK//pLyCdf5of8EyxY8MwA0XosEZoAzvaBT7948pw6wI1FS7Ar5qtcXv8MUOIQfgejTqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634558952; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=De8JJUfJuHggtaQiuyaWXufCKgzh8n1I3kNLyZeIzbs=; b=ZYr+UPsTMPUKoLSGuaZ13Ds0pe1KJpXDD+4tXuBZTweWquxBC0p4PFRwX4EM2p/3fhljTNahahomAA/+XiwH2Bo3mQ6AB1lPx1+FOgQyQBUyaimX8lsnTSrZFKC5vEjU6bHfaFOIaXT8K0vPTlJnSktbqaOcSiba2U+DNAudGl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1634558952082931.0715067601268; Mon, 18 Oct 2021 05:09:12 -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-245-3Sx50k_RMsyJQrEKDovqFQ-1; Mon, 18 Oct 2021 08:09:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24FEA19200C2; Mon, 18 Oct 2021 12:08:47 +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 78AC6226E9; Mon, 18 Oct 2021 12:08:46 +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 1B5F74EA2A; Mon, 18 Oct 2021 12:08:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19IC8gio012346 for ; Mon, 18 Oct 2021 08:08:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF57810023AB; Mon, 18 Oct 2021 12:08:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 245141002D71 for ; Mon, 18 Oct 2021 12:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634558950; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=De8JJUfJuHggtaQiuyaWXufCKgzh8n1I3kNLyZeIzbs=; b=fA7eXIRm81V/WklQgPoE05eWoPQJtPtuxq3yWBgUXEyFRdb2o2qa57h0nLIRUcJv7Aq1AM yehszF401dC6cxVgwPfCc02/VED+FKGO6coAE9Y+NkNXZ55kCIDWVx/VnIM+mBvzUue3IO 1kzovt4XO271gSqeL4jTduO/Cn3PnPI= X-MC-Unique: 3Sx50k_RMsyJQrEKDovqFQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2] virNodeDeviceDefParse: Don't call post-parse callbacks with NULL def Date: Mon, 18 Oct 2021 14:08:41 +0200 Message-Id: <83ad21cc65426b973dd2a119538aca0d50971240.1634558849.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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) X-ZM-MESSAGEID: 1634558952983100001 Content-Type: text/plain; charset="utf-8" When parsing of the node device XML fails we'd still call the post-parse and validation callbacks which makes no sense. Additionally the callbacks were expecting a non-NULL pointer which leads to a crash. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2014139 Fixes: d5ae634ba28 Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- v2: - Also handle failure of virXMLParse - add 'fails' into first sentence of commit message src/conf/node_device_conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 9bbff97ffd..1f39e2cbfd 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2177,10 +2177,10 @@ virNodeDeviceDefParse(const char *str, g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(virNodeDeviceDef) def =3D NULL; - if ((xml =3D virXMLParse(filename, str, _("(node_device_definition)"),= NULL, false))) { - def =3D virNodeDeviceDefParseNode(xml, xmlDocGetRootElement(xml), - create, virt_type); - } + if (!(xml =3D virXMLParse(filename, str, _("(node_device_definition)")= , NULL, false)) || + !(def =3D virNodeDeviceDefParseNode(xml, xmlDocGetRootElement(xml), + create, virt_type))) + return NULL; if (parserCallbacks) { int ret =3D 0; --=20 2.31.1