From nobody Mon Feb 9 16:44:53 2026 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=1616581649; cv=none; d=zohomail.com; s=zohoarc; b=a3++7IXyWiRIXIsnx+dBab7NELePkL7cmKXdBsyv55SpGgGu9W1XH6s0OWX/AbipYcCVB0S9j+4JoFbG+TZIFaAkNgpkhsb25mTtL+WBCRJFmoYUHz/vrdXKRK4YD+IN9GebXMdMyxPEXXf0Ub1CAaSOfrsbryZT4lVgdbJyU+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616581649; 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=Sd6co3aQR45+/Bof+txNcVEr/QX53hogrYKHvQWqhJo=; b=FWhZnUOTJePU5FT2cgtKELieLLhYD1w+DOFZcltQwbI53gHKRDIROcjhctXayyTT+g9RcouzZqz/UgslvDWdOklJRQk0JJgBDh4Oori3QZqLdLzE4wW5POEkKgK3XaINfyTxq7yNP2iStRIjAe3YZCUWxSFVvYxbbpJ5kkU/a3E= 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) header.from= 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 1616581649833977.5823534516182; Wed, 24 Mar 2021 03:27:29 -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-25-Na483_0FMNKhXJ0MMPI61A-1; Wed, 24 Mar 2021 06:27:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4CCC87A83E; Wed, 24 Mar 2021 10:27:19 +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 B049310013D7; Wed, 24 Mar 2021 10:27:18 +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 B25931809C84; Wed, 24 Mar 2021 10:27:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12OARDZw025467 for ; Wed, 24 Mar 2021 06:27:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE01A63C3F; Wed, 24 Mar 2021 10:27:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D8725FC1D for ; Wed, 24 Mar 2021 10:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616581648; 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=Sd6co3aQR45+/Bof+txNcVEr/QX53hogrYKHvQWqhJo=; b=EqqhWwGjo0FDiHyGLJPTJQOxEObGrBDq6WpBk4/B4F/nu0XhMhkOGzy/7Hachga5mmQnTb vWA60w38oYUWunP3FH1rEFdz4PFKXkRRxD0ee5huZMSFWf9FFpvgkAgCZumgHDV24yuAbZ AQ3svdZAbfpV+30seNoh7Y+c0ZcP/Fo= X-MC-Unique: Na483_0FMNKhXJ0MMPI61A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] esx: Fix @doms pointer steal in esxConnectListAllDomains() Date: Wed, 24 Mar 2021 11:27:06 +0100 Message-Id: <9137c0dc1eec27aaf6f25787ca96acca5b4255f8.1616581606.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.84 on 10.5.11.22 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" The ESX implementation of virConnectListAllDomains() follows pretty much implementations in other drivers: it has local array of virDomainPtr-s which (if requested by caller) is filled by actual domains or not (if the caller is interested only in the count of domains). Anyway, in case of the former, the passed @domains argument is set to the local array, which is then set to NULL to prevent it from freeing under cleanup label. Pretty standard pattern. Except, the local array is set to NULL always. Even if the local array is not stolen. Fortunately, this doesn't lead to a memory leak, because if caller is not interested in the array, none is allocated. But it doesn't set good example and also breaks my spatch rules. Signed-off-by: Michal Privoznik --- src/esx/esx_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 21705ef6e3..1c68776c18 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4929,9 +4929,10 @@ esxConnectListAllDomains(virConnectPtr conn, doms[count++] =3D dom; } =20 - if (doms) + if (doms) { *domains =3D doms; - doms =3D NULL; + doms =3D NULL; + } ret =3D count; =20 cleanup: --=20 2.26.2