From nobody Sun Feb 8 19:59:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1596475154; cv=none; d=zohomail.com; s=zohoarc; b=kETHminXNSNUpij3qDSy6Wl4OsvgCQ5fwvv9jQclfRplWUfArIhWlDs1CuVmY52ukd9vY9tjq4OfvFrn1AleoHVHn7jrMxouXa4+SIO218FdhOCSzRoJIu7gfgUtTqkNhExkdIlaL+59C0B1PEyp76YdtDMMuCXnkflm6ygy34s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596475154; 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=mw0K0rRbvz5SXJ5ebk6vp5nb1j+iLhqKO/vVe3ObqRI=; b=dY9HU+rRv89G+eTfeVabZgBb/oW+7xVUYe4L+q8Htx6XPq9bHRSfY2hUguLIGSgIPikaGaoSjt4BNKohVFvRGs3kDqBGOSrT9ANlU/JC5FLROGAVvfWfWsmaI1cUdDWK0/MEdfAw0pIOiFHEcRx7zACJbNn3rbLSTf+sj1vnVoA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1596475154793716.1086613050853; Mon, 3 Aug 2020 10:19:14 -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-410-UURv4UtwOji-1Ga2fVi2jA-1; Mon, 03 Aug 2020 13:19:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1ACA38064DD; Mon, 3 Aug 2020 17:19:05 +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 EEE8A87E3A; Mon, 3 Aug 2020 17:19:04 +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 BEEE89A109; Mon, 3 Aug 2020 17:19:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 073HJ0hk011035 for ; Mon, 3 Aug 2020 13:19:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id B652487E2C; Mon, 3 Aug 2020 17:19:00 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BA4F7852C for ; Mon, 3 Aug 2020 17:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596475153; 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=mw0K0rRbvz5SXJ5ebk6vp5nb1j+iLhqKO/vVe3ObqRI=; b=HIMY5CeGYTIAvf8sk7qOJ621whYfnp+VE1fRqk1b89DqnF4XMyePFGnqmuI8xgwkOsY2A6 N4Enxxdl9TguQ7N4TK8RYlCyFIA+1XxHjyQwTOWycK29W+OB7I8nNswE6JO5MHUs37lOiB In1B2nqKKDsz+QSt9OTdO8PITJumFPo= X-MC-Unique: UURv4UtwOji-1Ga2fVi2jA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/3] bhyve: fix NULL pointer check position Date: Mon, 3 Aug 2020 19:18:51 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) src/bhyve/bhyve_parse_command.c:437:9: warning: Either the condition '!config' is redundant or there is possible null pointer dereference: config. [nullPointerRedundantCheck] src/bhyve/bhyve_parse_command.c:280:23: warning: Either the condition '!separator' is redundant or there is pointer arithmetic with NULL pointer. [nullPointerArithmeticRedundantCheck] Signed-off-by: J=C3=A1n Tomko Reviewed-by: Roman Bogorodskiy --- src/bhyve/bhyve_parse_command.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index b2d2280872..5e9cf7ba13 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -277,11 +277,11 @@ bhyveParseBhyveLPCArg(virDomainDefPtr def, char *type =3D NULL; =20 separator =3D strchr(arg, ','); + + if (!separator) + goto error; + param =3D separator + 1; - - if (!separator) - goto error; - type =3D g_strndup(arg, separator - arg); =20 /* Only support com%d */ @@ -434,14 +434,14 @@ bhyveParsePCIDisk(virDomainDefPtr def, disk->info.addr.pci.slot =3D pcislot; disk->info.addr.pci.function =3D function; =20 + if (!config) + goto error; + if (STRPREFIX(config, "/dev/")) disk->src->type =3D VIR_STORAGE_TYPE_BLOCK; else disk->src->type =3D VIR_STORAGE_TYPE_FILE; =20 - if (!config) - goto error; - separator =3D strchr(config, ','); if (separator) disk->src->path =3D g_strndup(config, separator - config); --=20 2.26.2