From nobody Sun May 5 13:45:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1685515848; cv=none; d=zohomail.com; s=zohoarc; b=d25XAh2jua/CpPfgWSLbp8yTh7eQFA6YOHgRMR9uYcCDsfWJ2/m7/MiZUe0nC3BEpeIN1RYC7CSGzRg/3sVgtz1Nxb1/VMcuu/kw1YzcUlad4H3YjSbDsZInNJDZULygjcmfFZBi9HfyWD4cXBF6523KxAMn4iBxcnRJSu2lBJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685515848; 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=GY1d4FCkZA7/A8fprL9mRZ55hwfFnV2h/nEt85XEJrg=; b=PtwsCO9kYwlhi01F933lveWH/1VLfVDUGNFYln0IPOl2pDaY8g7xqU+W1/AlYKpQviX8IB8FoJs4RXPq0VH4owM8SlpzCGvlveVqivdv4rR6a2AdW9Ae8ZGU29gXB4SAMsDYEl8OdBkymy/bDeiAhym9mn1AdDbUmmChNQXdhBI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1685515848750132.00894896817306; Tue, 30 May 2023 23:50:48 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-353-eIGBISKZOtSY6QdHIB4o5Q-1; Wed, 31 May 2023 02:50:45 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06932380353D; Wed, 31 May 2023 06:50:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 532DD48205E; Wed, 31 May 2023 06:50:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 221B819465A0; Wed, 31 May 2023 06:50:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 07C9D1946595 for ; Wed, 31 May 2023 06:50:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D731A492B0D; Wed, 31 May 2023 06:50:39 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.225.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DED6492B0A for ; Wed, 31 May 2023 06:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685515847; 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=GY1d4FCkZA7/A8fprL9mRZ55hwfFnV2h/nEt85XEJrg=; b=SEX/ylXLW0r3gH5ycz/hgY3jiSPm+i57UauVSG41t7+tidlnVv2cTKIC3+zm0MuUzHbyi7 +yzCHhLw0q44ZJfZ/dRfeaUqXBdjN8+U6klf6L2oTFgziPO8RQsGp0bp/JQ5AutxV3FX1K eUoczQlinUSwFhvwqWK2vIqgFwZEGQA= X-MC-Unique: eIGBISKZOtSY6QdHIB4o5Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv2] conf: node_device: use separate variables for parsing integers Date: Wed, 31 May 2023 08:50:36 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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) X-ZM-MESSAGEID: 1685515849686100001 In virNodeDeviceGetSCSIHostCaps, there is a pattern of reusing a tmp value and stealing the pointer. But in two case it is not stolen. Use separate variables for them to avoid mixing autofree with manual free() calls. Fixes: 8a0cb5f73ade3900546718eabe70cb064c6bd22c Signed-off-by: J=C3=A1n Tomko --- v2: also replace the variable name in the error message and fix one more ca= se src/conf/node_device_conf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index fcee9c027c..48a47f0f86 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2858,28 +2858,30 @@ virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHost = *scsi_host) =20 if (virVHBAIsVportCapable(NULL, scsi_host->host)) { scsi_host->flags |=3D VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS; + g_autofree char *max_vports =3D NULL; + g_autofree char *vports =3D NULL; =20 - if (!(tmp =3D virVHBAGetConfig(NULL, scsi_host->host, + if (!(max_vports =3D virVHBAGetConfig(NULL, scsi_host->host, "max_npiv_vports"))) { VIR_WARN("Failed to read max_npiv_vports for host%d", scsi_host->host); goto cleanup; } =20 - if (virStrToLong_i(tmp, NULL, 10, &scsi_host->max_vports) < 0) { - VIR_WARN("Failed to parse value of max_npiv_vports '%s'", tmp); + if (virStrToLong_i(max_vports, NULL, 10, &scsi_host->max_vports) <= 0) { + VIR_WARN("Failed to parse value of max_npiv_vports '%s'", max_= vports); goto cleanup; } =20 - if (!(tmp =3D virVHBAGetConfig(NULL, scsi_host->host, + if (!(vports =3D virVHBAGetConfig(NULL, scsi_host->host, "npiv_vports_inuse"))) { VIR_WARN("Failed to read npiv_vports_inuse for host%d", scsi_host->host); goto cleanup; } =20 - if (virStrToLong_i(tmp, NULL, 10, &scsi_host->vports) < 0) { - VIR_WARN("Failed to parse value of npiv_vports_inuse '%s'", tm= p); + if (virStrToLong_i(vports, NULL, 10, &scsi_host->vports) < 0) { + VIR_WARN("Failed to parse value of npiv_vports_inuse '%s'", vp= orts); goto cleanup; } } --=20 2.40.1