From nobody Sun Feb 8 22:08:28 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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=1615823201; cv=none; d=zohomail.com; s=zohoarc; b=CUYNraMiFZa0j56bSV6OBKNK57yGx5bcJtJwClpctvuP/aC9WDwt3cxuTBWCRYvP4s8+mY0xG+wDLRo8nQZs6ufQpxJbOf8KZGXYRWPofBEgRZEo8EhvNxlERcojRaDvodfnWKYRMd5SzDdvKJWo1Sv7dV+8pVuGk1uzliKLzW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615823201; 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=d6dWIdShbCCn27pYS5f2kOuYr+HY4Om43FhcLMX6FEg=; b=PdJaPf+l/hWHL0hgQsk5CWh8aCVnMrZIRfRQNTIWD6Uijrk8PJJGHtB817Xpm8HYu3XmlMqcKLVzZqT+/lj9ejTI94ccqBVqQ3ALJmaUsDMhX6VeWi1xwE9axE1L8xE+47MZRCO6i3OyUlye9j/vkvy38DSVhM+8GPt1F/b7E5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1615823201515201.885527397018; Mon, 15 Mar 2021 08:46:41 -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-578-01KvtIIAMDyLWX48dUrajA-1; Mon, 15 Mar 2021 11:46:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8B1D100D671; Mon, 15 Mar 2021 15:46:31 +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 7666B5C5E0; Mon, 15 Mar 2021 15:46:31 +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 18BD318155DE; Mon, 15 Mar 2021 15:46:31 +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 12FFkHnF025111 for ; Mon, 15 Mar 2021 11:46:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2566A10190A7; Mon, 15 Mar 2021 15:46:17 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 883EE100164C for ; Mon, 15 Mar 2021 15:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615823200; 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=d6dWIdShbCCn27pYS5f2kOuYr+HY4Om43FhcLMX6FEg=; b=Ylpr1v+lVePKrENLOGhYl7jmmUcfcCK90Y+IV+WH5dX/3aiKqwaxZsgh+ItZIV4uf2sTKs 2SB5rAVj0NCJIiycSLKQEkztCDHlI8sfETo88EIxzZNH1A1si1y6gD5bCVKXShBxjAO9ym pqu1kE0p2Cy2QV6sCyWCbRoWdR1C/OI= X-MC-Unique: 01KvtIIAMDyLWX48dUrajA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] nss: findLease: do not leak path Date: Mon, 15 Mar 2021 16:46:08 +0100 Message-Id: <93305f5787ffcf5aef6a3be259633d4300d0c14a.1615823130.git.jtomko@redhat.com> In-Reply-To: References: 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.16 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 X-ZohoMail-DKIM: pass (identity @redhat.com) We still check for realloc's return value in the nss module. Free the path in case it fails before jumping to cleanup. Signed-off-by: J=C3=A1n Tomko --- tools/nss/libvirt_nss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index b021efc3c9..87a731da79 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -138,8 +138,10 @@ findLease(const char *name, goto cleanup; =20 tmpLease =3D realloc(leaseFiles, sizeof(char *) * (nleaseFiles= + 1)); - if (!tmpLease) + if (!tmpLease) { + free(path); goto cleanup; + } leaseFiles =3D tmpLease; leaseFiles[nleaseFiles++] =3D path; #if defined(LIBVIRT_NSS_GUEST) --=20 2.29.2