From nobody Mon Feb 9 06:00:02 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=1606913034; cv=none; d=zohomail.com; s=zohoarc; b=hlJzO7s4ENfM2JW4jnmt0ntYwFbsG8VX+NX78ffsu62AemInE8Bn7TmLzAFUTQ+kTxPXVE4BA5aaicgPgAK5zjPOZJkxyt1nCgghIzWi3Iori5jjgQxBuZ8WtTbY9r9WNx/6O8/Eexhshx8VHzrX5wmsCnQ0RQ1SfNWKORBDw8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606913034; 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=t1PxhgU/SPU71Km7mz06PQNwgwZS6ZAr1GreudbvfBU=; b=P86wLSqJWw310xftJarPTwSHPe1QzzbJehH3CDefA5LFsaEmKXQV3uSvSXP2HeRCnhA7khLJzwAj42U1WUQA3286+oQhZJXrzfSBxd21GkzlpBC7iGwB43Ob3yasC+KYeJfVOZgrhNCmQp7gBLgrA8PpWUzVwmxPPtT2cxVntug= 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 1606913034515280.518102396843; Wed, 2 Dec 2020 04:43:54 -0800 (PST) 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-429-b4j_9np2PaqC2SYDUZM40Q-1; Wed, 02 Dec 2020 07:43:51 -0500 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 10943100C616; Wed, 2 Dec 2020 12:43:43 +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 DF4825C1B4; Wed, 2 Dec 2020 12:43:42 +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 819281809CA3; Wed, 2 Dec 2020 12:43:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B2ChSHX003703 for ; Wed, 2 Dec 2020 07:43:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8761460C0F; Wed, 2 Dec 2020 12:43:28 +0000 (UTC) Received: from fedora.redhat.com (ovpn-112-197.phx2.redhat.com [10.3.112.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AC5F60BFA for ; Wed, 2 Dec 2020 12:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606913033; 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=t1PxhgU/SPU71Km7mz06PQNwgwZS6ZAr1GreudbvfBU=; b=Ny+5TT5Pe7jId1JofWLWLRVXGSaj1b1d5jIZydsjX+Ubc3F0pRZ0SeuY2zb0ubyrMMpxcq LRz7dnxs92Zkm+hZ7pqkQtNE6lNq4kxXdkAf2j/Sppv/rYrVhAZD7V0WbPAQ4whDg94ush BynGo8vJIfmpfWdQxcyah6LVXzsx2NM= X-MC-Unique: b4j_9np2PaqC2SYDUZM40Q-1 From: John Ferlan To: libvir-list@redhat.com Subject: [PATCH 6/7] locking: Resolve mem leak in virLockDaemonPreExecRestart Date: Wed, 2 Dec 2020 07:43:20 -0500 Message-Id: <20201202124321.765271-7-jferlan@redhat.com> In-Reply-To: <20201202124321.765271-1-jferlan@redhat.com> References: <20201202124321.765271-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Initialize and free @magic since virJSONValueObjectAppendString does not free it for us eventually. Signed-off-by: John Ferlan Reviewed-by: J=C3=A1n Tomko --- src/locking/lock_daemon.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 57c7fb088f..851e9fc6f0 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -700,7 +700,7 @@ virLockDaemonPreExecRestart(const char *state_file, virJSONValuePtr child; char *state =3D NULL; virJSONValuePtr object =3D virJSONValueNewObject(); - char *magic; + char *magic =3D NULL; virHashKeyValuePairPtr pairs =3D NULL, tmp; virJSONValuePtr lockspaces; =20 @@ -748,10 +748,8 @@ virLockDaemonPreExecRestart(const char *state_file, if (!(magic =3D virLockDaemonGetExecRestartMagic())) goto cleanup; =20 - if (virJSONValueObjectAppendString(object, "magic", magic) < 0) { - VIR_FREE(magic); + if (virJSONValueObjectAppendString(object, "magic", magic) < 0) goto cleanup; - } =20 if (!(state =3D virJSONValueToString(object, true))) goto cleanup; @@ -775,6 +773,7 @@ virLockDaemonPreExecRestart(const char *state_file, abort(); /* This should be impossible to reach */ =20 cleanup: + VIR_FREE(magic); VIR_FREE(pairs); VIR_FREE(state); virJSONValueFree(object); --=20 2.28.0