From nobody Sun May 5 23:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491986677469148.52985843039596; Wed, 12 Apr 2017 01:44:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3BF0627C5; Wed, 12 Apr 2017 08:44:35 +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 94D58C05A4; Wed, 12 Apr 2017 08:44:35 +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 D6C9018523C7; Wed, 12 Apr 2017 08:44:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3C8iX0N024975 for ; Wed, 12 Apr 2017 04:44:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id A7FFA92D93; Wed, 12 Apr 2017 08:44:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E7C792D96 for ; Wed, 12 Apr 2017 08:44:30 +0000 (UTC) Received: from dggrg02-dlp.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15D7CC04BD41 for ; Wed, 12 Apr 2017 08:44:28 +0000 (UTC) Received: from 172.30.72.56 (EHLO dggeml405-hub.china.huawei.com) ([172.30.72.56]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ALL70820; Wed, 12 Apr 2017 16:44:25 +0800 (CST) Received: from localhost (10.177.17.7) by dggeml405-hub.china.huawei.com (10.3.17.49) with Microsoft SMTP Server id 14.3.301.0; Wed, 12 Apr 2017 16:44:19 +0800 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F3BF0627C5 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F3BF0627C5 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15D7CC04BD41 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=king.wang@huawei.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 15D7CC04BD41 From: Wang King To: Date: Wed, 12 Apr 2017 16:44:04 +0800 Message-ID: <20170412084404.34372-1-king.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.17.7] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.58EDE8E9.0207, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: caf645ed99cfa23236647ed12ec5a9ab X-Greylist: Delayed for 01:07:39 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 12 Apr 2017 08:44:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 12 Apr 2017 08:44:28 +0000 (UTC) for IP:'45.249.212.188' DOMAIN:'szxga02-in.huawei.com' HELO:'dggrg02-dlp.huawei.com' FROM:'king.wang@huawei.com' RCPT:'' X-RedHat-Spam-Score: 0.398 (BAYES_50, DCC_REPUT_00_12, RP_MATCHES_RCVD, SPF_PASS) 45.249.212.188 szxga02-in.huawei.com 45.249.212.188 szxga02-in.huawei.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: yanqiangjun@huawei.com, weidong.huang@huawei.com, Wang King , weifuqiang@huawei.com Subject: [libvirt] [PATCH] util: Fix resource leak 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Apr 2017 08:44:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The virRotatingFileWriterAppend method leaks the file->entry on the virRotatingFileWriterEntryNew failing path. --- src/util/virrotatingfile.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util/virrotatingfile.c b/src/util/virrotatingfile.c index 9144729..83a695f 100644 --- a/src/util/virrotatingfile.c +++ b/src/util/virrotatingfile.c @@ -483,18 +483,19 @@ virRotatingFileWriterAppend(virRotatingFileWriterPtr = file, =20 if ((file->entry->pos =3D=3D file->maxlen && len) || forceRollover) { - virRotatingFileWriterEntryPtr tmp =3D file->entry; + virRotatingFileWriterEntryPtr tmp; VIR_DEBUG("Hit max size %zu on %s (force=3D%d)\n", file->maxlen, file->basepath, forceRollover); =20 if (virRotatingFileWriterRollover(file) < 0) return -1; =20 - if (!(file->entry =3D virRotatingFileWriterEntryNew(file->base= path, - file->mode))) + if (!(tmp =3D virRotatingFileWriterEntryNew(file->basepath, + file->mode))) return -1; =20 - virRotatingFileWriterEntryFree(tmp); + virRotatingFileWriterEntryFree(file->entry); + file->entry =3D tmp; } } =20 --=20 2.8.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list