Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp479322pxb; Wed, 8 Sep 2021 05:44:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2UUcl6748V9eO19j9HxHppXreuZmzlEC1PSvXfqyQcITT8yTkow3+NVg2cfK1mTVXELUz X-Received: by 2002:a17:906:1299:: with SMTP id k25mr3809541ejb.139.1631105065507; Wed, 08 Sep 2021 05:44:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631105065; cv=none; d=google.com; s=arc-20160816; b=tQJHwA5zjPJ5ZuSOYnFodGYWY5mFKIBNWPWbIgMOedxQeP+mp1k7RZmoNbby2vTGYj vXWM4vQdl+RmoiPb50mCZu+EKwAqa1YVZFTLdSGD+XL33LHYBGf+Fl1/9DeV8u5SEdzv kr+P9DstMHUE0tovggxzz71pWvUPF/CKLC+MCYHPVB3TDEFxk3I6+lSI5tXAUmFEzt2N 1M6thYm+bsBflvVyOOAxdfNLP3j48FRURf9RW/246TPOLeQWb4XiZSLwDsnImINGtR0Q PCnL2Ruh57O1o42kkkS2wSE2YB1+tWeMUnbRtwGbo/1e70dMlVhULV54k1RljX91KIx4 5E9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=PasELBMKnHXGHIi4fbp8LpPzJvUF7LK8fU26ks2KGUI=; b=kI5f4KTl6d6Xefqkl3pMVCJxCcZmAtbH7wTu5aoU6mTT/7WD8E3+vgstNTjSoW8VJy wJt1SHzCamU+8nTiC3JqqSFrFkbKgbV5T+8k8Au2zYPrEHnN3TmukX/NR89XPfgSpWao 6RtEpNVOCCBRz1eGvZ4iByWZnpKRKeG7sBBY1n5WfLSqg5eT2zOy9t8ldJJHR8Z5YC+u IrAK8uH8IXmw+L8nh9t3cn8tCZjbp7jMnf48cgObSz4ZHkywg6Rb+4+QBMDPH1MOtI2B POHxCz5tuluPVlGr9ExY9bjM++oYf0J7Gzb58ffY3p9PXxn9zncHu0BpBt2HUGmT0Jfb b9Ig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si2735382edl.348.2021.09.08.05.44.00; Wed, 08 Sep 2021 05:44:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347072AbhIHKw4 (ORCPT + 99 others); Wed, 8 Sep 2021 06:52:56 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:33544 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347300AbhIHKww (ORCPT ); Wed, 8 Sep 2021 06:52:52 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R961e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UngnLi9_1631098292; Received: from B-D1K7ML85-0059.local(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0UngnLi9_1631098292) by smtp.aliyun-inc.com(127.0.0.1); Wed, 08 Sep 2021 18:51:33 +0800 Subject: Re: [PATCH v2] ocfs2: Fix handle refcount leak in two exception handling paths To: Chenyuan Mi , akpm Cc: yuanxzhang@fudan.edu.cn, Xiyu Yang , Xin Tan , Mark Fasheh , Joel Becker , ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org References: <20210908102055.10168-1-cymi20@fudan.edu.cn> From: Joseph Qi Message-ID: <06d9e055-29b9-731c-5a36-d888f2c83188@linux.alibaba.com> Date: Wed, 8 Sep 2021 18:51:32 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210908102055.10168-1-cymi20@fudan.edu.cn> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/8/21 6:20 PM, Chenyuan Mi wrote: > The reference counting issue happens in two exception handling paths > of ocfs2_replay_truncate_records(). When executing these two exception > handling paths, the function forgets to decrease the refcount of handle > increased by ocfs2_start_trans(), causing a refcount leak. > > Fix this issue by using ocfs2_commit_trans() to decrease the refcount > of handle in two handling paths. > > Signed-off-by: Chenyuan Mi > Signed-off-by: Xiyu Yang > Signed-off-by: Xin Tan Reviewed-by: Joseph Qi > --- > fs/ocfs2/alloc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c > index f1cc8258d34a..b05fde7edc3a 100644 > --- a/fs/ocfs2/alloc.c > +++ b/fs/ocfs2/alloc.c > @@ -5940,6 +5940,7 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, > status = ocfs2_journal_access_di(handle, INODE_CACHE(tl_inode), tl_bh, > OCFS2_JOURNAL_ACCESS_WRITE); > if (status < 0) { > + ocfs2_commit_trans(osb, handle); > mlog_errno(status); > goto bail; > } > @@ -5964,6 +5965,7 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, > data_alloc_bh, start_blk, > num_clusters); > if (status < 0) { > + ocfs2_commit_trans(osb, handle); > mlog_errno(status); > goto bail; > } >