From nobody Fri Apr 26 04:38:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1595494438; cv=none; d=zohomail.com; s=zohoarc; b=DmQUIQzXiISBy6bKHn7Akv9qKJc+rwqlnWo0K9gBfyrpejEsdusIGFNQ+Pk4l09vr4qc3x4YF4mS711jU/J2cRW8RCqyp7snQ806BKp48+MotWshul2GJJ0Q+PRZOF2DQe4hemfs3mxN1ncQnf7cTIpgcRJNLYPSTBgjjUxDbVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595494438; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=mWGYG1xCp8UslrzD/S1YE9eGiJ97+vsrnUoecruYnGo=; b=gki+L903Nj5feWRbOgG4KEtKOM0eiScNsLTC8KCxC0i+yClJo67JNHKdZBx6ex/plOTjJQ5APDrlbr+FDyV02ayZ+bHI5oAqzII3GKJBgXd2/Nw5zztdLgT8hFDQuiT3dTB/BDZw6EKaOqS3XOUg4aBwoCIvp1ytqOADJMlAB6g= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1595494438479724.5380719578499; Thu, 23 Jul 2020 01:53:58 -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-109-Asj0HWvgObKoSlbNvOoKxg-1; Thu, 23 Jul 2020 04:53:55 -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 85621106B243; Thu, 23 Jul 2020 08:53:48 +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 ECBD55C1BB; Thu, 23 Jul 2020 08:53:47 +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 1B51194EE3; Thu, 23 Jul 2020 08:53:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06N1jJ85021588 for ; Wed, 22 Jul 2020 21:45:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id D85F22026D67; Thu, 23 Jul 2020 01:45:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C47A62026D5D for ; Thu, 23 Jul 2020 01:45:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DA71D8007A4 for ; Thu, 23 Jul 2020 01:45:15 +0000 (UTC) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-275-7PbqGmYvM0aY4h62aLJb1Q-1; Wed, 22 Jul 2020 21:45:12 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8BD0ACC056D7F27E0EF9 for ; Thu, 23 Jul 2020 09:29:11 +0800 (CST) Received: from [127.0.0.1] (10.174.187.164) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Thu, 23 Jul 2020 09:29:02 +0800 X-MC-Unique: Asj0HWvgObKoSlbNvOoKxg-1 X-MC-Unique: 7PbqGmYvM0aY4h62aLJb1Q-1 To: From: Hao Wang Subject: [PATCH] client: fix memory leak in client msg Message-ID: Date: Thu, 23 Jul 2020 09:29:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 X-Originating-IP: [10.174.187.164] X-CFilter-Loop: Reflected X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Thu, 23 Jul 2020 04:53:44 -0400 Cc: alex.chen@huawei.com, zhengchuan@huawei.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 Content-Type: text/plain; charset="utf-8" >From 3ad3fae4f2562a11bef8dcdd25b6a7e0b00d4e2c Mon Sep 17 00:00:00 2001 From: Hao Wang Date: Sat, 18 Jul 2020 15:43:30 +0800 Subject: [PATCH] client: fix memory leak in client msg When closing client->waitDispatch in virNetClientIOEventLoopRemoveAll or virNetClientIOEventLoopRemoveDone, VIR_FREE() is called to free call->msg directly, resulting in leak of the memory call->msg->buffer points to. Use virNetMessageFree(call->msg) instead of VIR_FREE(call->msg). Signed-off-by: Hao Wang Reviewed-by: Jonathon Jongsma Reviewed-by: J=C3=A1n Tomko --- src/rpc/virnetclient.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 441f1502a6..f899493b64 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1519,7 +1519,7 @@ static bool virNetClientIOEventLoopRemoveDone(virNetC= lientCallPtr call, if (call->expectReply) VIR_WARN("Got a call expecting a reply but without a waiting t= hread"); virCondDestroy(&call->cond); - VIR_FREE(call->msg); + virNetMessageFree(call->msg); VIR_FREE(call); } @@ -1546,7 +1546,7 @@ virNetClientIOEventLoopRemoveAll(virNetClientCallPtr = call, VIR_DEBUG("Removing call %p", call); virCondDestroy(&call->cond); - VIR_FREE(call->msg); + virNetMessageFree(call->msg); VIR_FREE(call); return true; } -- 2.23.0