From nobody Sun May 5 00:07:47 2024 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=1615823189; cv=none; d=zohomail.com; s=zohoarc; b=LJyW5A+8IaeTWT5QmxIUf8/pE3DPJkwPIiE19+ZshqpBHP/iUaE8vwJ16jR+cB33ZzcWZ49P2hUalTZ754x18JQwzSEEqr5/5/heyatmaCkvSCj4IKsjCAU5FT6VXVASlhHgrHjrSwf4PbCY+nDLLcLiiba2xBo2k0v6WN/Q9MU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615823189; 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=r7VWHwxE52kk52YURBJybMonuSgiF440hR/JBJNQoFU=; b=eVDAKKYY1+P4Z5upyZgDEdWLAagS9KdA5BpLqVkBk9sIJfbUXUwEotcOt3lTTa3VCYCEyF6hjnpsv0xJJt66LaderXb7FEEUEv4ov0Z7KIuQMHdUA3myw2NEqogfibqZvQqwkjdhw6rNRAnZui76edHE0EJD8Nhs/IUw5pO6tCA= 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 1615823189835689.8481872545146; Mon, 15 Mar 2021 08:46: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-516-JOdM1dcAPOK1gy1qDkhc_A-1; Mon, 15 Mar 2021 11:46:26 -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 F33FB839A47; Mon, 15 Mar 2021 15:46:20 +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 DAF185C5E0; Mon, 15 Mar 2021 15:46:19 +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 439D54EA30; Mon, 15 Mar 2021 15:46:19 +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 12FFkGWi025098 for ; Mon, 15 Mar 2021 11:46:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 24E43100164C; Mon, 15 Mar 2021 15:46:16 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B73010190A7 for ; Mon, 15 Mar 2021 15:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615823188; 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=r7VWHwxE52kk52YURBJybMonuSgiF440hR/JBJNQoFU=; b=hQK52ye7Wx/VPsTbecd5P0YX9p7AVXc6j8azX8Ew3Pmb8+vGpMepTxsqi1uZAp9qYQgMKR Buxe26ONLzQSaDusMyxFRnBajNNIF9h/s9VcetBs8OG7SyUNew9oCdKN1jVOfy7XLWmbbD abAnl+CuSVo5ir/pLSJ2UWA+hNR37Pw= X-MC-Unique: JOdM1dcAPOK1gy1qDkhc_A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] cmdList: mark title as autofree Date: Mon, 15 Mar 2021 16:46:07 +0100 Message-Id: <18f6b958d37d53dab09bf19e237bf92895e4f1dd.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) Fixes the (im)possible memory leak on vshTableRowAppend failure. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- tools/virsh-domain-monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 897339b6f9..fcbc2fe9f0 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1961,7 +1961,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd) bool optName =3D vshCommandOptBool(cmd, "name"); bool optID =3D vshCommandOptBool(cmd, "id"); size_t i; - char *title; char uuid[VIR_UUID_STRING_BUFLEN]; int state; bool ret =3D false; @@ -2044,6 +2043,8 @@ cmdList(vshControl *ctl, const vshCmd *cmd) state =3D -2; =20 if (optTitle) { + g_autofree char *title =3D NULL; + if (!(title =3D virshGetDomainDescription(ctl, dom, true, = 0))) goto cleanup; if (vshTableRowAppend(table, id_buf, @@ -2052,7 +2053,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd) : virshDomainStateToString(state), title, NULL) < 0) goto cleanup; - VIR_FREE(title); } else { if (vshTableRowAppend(table, id_buf, virDomainGetName(dom), --=20 2.29.2 From nobody Sun May 5 00:07:47 2024 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 Reviewed-by: Michal Privoznik --- 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