From patchwork Wed May 1 04:06:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Qi X-Patchwork-Id: 2836831 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7C835C0319 for ; Thu, 1 Aug 2013 07:28:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67AF220233 for ; Thu, 1 Aug 2013 07:28:12 +0000 (UTC) Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E11C20266 for ; Thu, 1 Aug 2013 07:28:11 +0000 (UTC) Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r717S1hF026618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Aug 2013 07:28:02 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r717S1ve003928 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Aug 2013 07:28:01 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1V4nIm-0005gV-Un; Thu, 01 Aug 2013 00:28:00 -0700 Received: from acsinet21.oracle.com ([141.146.126.237]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1UXOJc-0000sF-0V for ocfs2-devel@oss.oracle.com; Tue, 30 Apr 2013 21:06:48 -0700 Received: from aserp1020.oracle.com (aserp1020.oracle.com [141.146.126.67]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4146lib007197 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 1 May 2013 04:06:47 GMT Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [119.145.14.65]) by aserp1020.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r4146ilr004210 (version=TLSv1/SSLv3 cipher=DES-CBC3-SHA bits=168 verify=FAIL) for ; Wed, 1 May 2013 04:06:46 GMT Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BAX49629; Wed, 01 May 2013 12:06:43 +0800 (CST) Received: from SZXEML408-HUB.china.huawei.com (10.82.67.95) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.1.323.7; Wed, 1 May 2013 12:06:41 +0800 Received: from SZXEML521-MBS.china.huawei.com ([169.254.8.20]) by szxeml408-hub.china.huawei.com ([10.82.67.95]) with mapi id 14.01.0323.007; Wed, 1 May 2013 12:06:35 +0800 From: "Qijiang (Joseph)" To: "jlbec@evilplan.org" Thread-Topic: [PATCH] ocfs2: fix possible memory leak in dlm_process_recovery_data Thread-Index: Ac5GIUMP5TDV9udfQ76B6cE3dt6UGA== Date: Wed, 1 May 2013 04:06:35 +0000 Message-ID: <51182BCE12D4834EA8164B99A509EABB32CDA65F@szxeml521-mbs.china.huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.135.64.116] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Flow-Control-Info: class=Pass-to-MM reputation=ipRisk-All ip=119.145.14.65 ct-class=R3 ct-vol1=0 ct-vol2=6 ct-vol3=5 ct-risk=10 ct-spam1=0 ct-spam2=0 ct-bulk=91 rcpts=1 size=1216 X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.0 cv=MYRFSuDf c=1 sm=1 a=qbZWUeANkjeORAZY4leFnw==:17 a=0JQp9YiEBiYA:10 a=zr5mchP9CeUA:10 a=O9dq5j03pVQA:10 a=_l4uJm6h9gAA:10 a=i0EeH86SAAAA:8 a=fb06pf96x2EA:10 a=J_mMtGndVncMoZ_9KVcA:9 a=mFyHDrcPJccA:10 a=hPjdaMEvmhQA:10 a=qbZWUeANkj eORAZY4leFnw==:117 X-Sendmail-CT-Classification: not spam X-Sendmail-CT-RefID: str=0001.0A090202.518094D7.0030:SCFSTAT1612107, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-Mailman-Approved-At: Thu, 01 Aug 2013 00:27:57 -0700 Cc: "Duyongfeng \(B\)" , "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH] ocfs2: fix possible memory leak in dlm_process_recovery_data X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We create newlock each time in dlm_process_recovery_data, but we don't free it when it is bad, and then it will lead to memory leak. Signed-off-by: Joseph Qi --- fs/ocfs2/dlm/dlmrecovery.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 1.7.9.7 diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index eeac97b..93de2e0 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -1974,6 +1974,12 @@ skip_lvb: res->lockname.len, res->lockname.name, ml->node); dlm_lockres_set_refmap_bit(dlm, res, ml->node); added++; + } else { + /* should free newlock if it is bad */ + if (newlock) { + dlm_lock_put(newlock); + newlock = NULL; + } } spin_unlock(&res->spinlock); }