From patchwork Fri Nov 25 03:41:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lihongweizz X-Patchwork-Id: 25796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3749448wrr; Thu, 24 Nov 2022 19:45:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf76g0mLoljOU/1wX4YMRKw4dUDH2z+QKBSMJPEv1rxyQ0jXyV9B3xNZiwNVVCKd9gF/c9s9 X-Received: by 2002:a63:dd13:0:b0:46e:ccbd:b136 with SMTP id t19-20020a63dd13000000b0046eccbdb136mr18234121pgg.515.1669347931660; Thu, 24 Nov 2022 19:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669347931; cv=none; d=google.com; s=arc-20160816; b=IY0RPjLcIwkWCty+4C8GXZj+EYQzFK0Td3OJjzQFZh3RIQHx9m5ikNtGznu2/GV4aM /p3bXZpAn+8uKzoA08sBmOPTjEY+Zw8Lqq+kuYNeslWz3yABxzZwZJMY89yjwfTEDjYA K+JD0VZ/+ueH3w/YP1Zxfr9aKzL/HcfmTSB+slOaNdcyvkUcQA/GuGCHNNEuQ9TBh+Rp SdMdOdTz6Gbgfvr+WLoYj29h53HHZsHx8AhWkqMz9AaTOGsw0f/vyeG10HPU6uLiuJnn aD/Ww7ZQql5zQQJUlz/JSu91PutUxx9ePtc3TGr8ICPlOEbIqTHOEwDXAaY+evjrS0+r /EvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:abuse-reports-to:tuid:mime-version:message-id :date:subject:cc:to:from; bh=6VmIrC6BrlMkFkIvL11pTCDSMy1fTfrwl+rIXy8vhxw=; b=n4H44CTn1C8GsLYm4icUvSxR4pVA/9ta/km0fbI7mKEf3idvsNmWHlwxnbBuSNbDnn Tq7cy/VcfU3Z1a5nH4GCCRcfLoor9bbJI0FLohMM5FGfSw2GGIoZbjfxwfPGiNWbcyJj fh1s974T+GgOE7A7/QMyvidqjwrY/zHzHvvLrxqumxV2Yk6OTqAL+JakwTUeVYn7WNIW ObdwAdRf3zIVLbcVfFhW9M33sa771TZvAz4V3mpdw4MAFgNV8dnhUb/YpYcT7c0kNtND tEp86nJX7Is1Gc4jOBXKR8GpqdYC8G7Ola+eK9pRsDJwZVg6Ew1CcP+D//TV/pYD6fUC 4llA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l20-20020a056a0016d400b005739d652ab4si2820313pfc.286.2022.11.24.19.45.18; Thu, 24 Nov 2022 19:45:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229471AbiKYDmE (ORCPT + 99 others); Thu, 24 Nov 2022 22:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiKYDmD (ORCPT ); Thu, 24 Nov 2022 22:42:03 -0500 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB14B1182B for ; Thu, 24 Nov 2022 19:42:01 -0800 (PST) Received: from ([60.208.111.195]) by unicom145.biz-email.net ((D)) with ASMTP (SSL) id TEO00022; Fri, 25 Nov 2022 11:41:22 +0800 Received: from lihongweizz00.home.langchao.com (10.93.221.219) by jtjnmail201611.home.langchao.com (10.100.2.11) with Microsoft SMTP Server id 15.1.2507.12; Fri, 25 Nov 2022 11:41:22 +0800 From: lihongweizz To: , , CC: , , lihongweizz Subject: [PATCH] ocfs2: fix infinite loop for orphan entry list Date: Fri, 25 Nov 2022 11:41:18 +0800 Message-ID: <20221125034118.427-1-lihongweizz@inspur.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.93.221.219] tUid: 20221125114123bca5f4d50778c114cbf93989e7e66be2 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750438176779120029?= X-GMAIL-MSGID: =?utf-8?q?1750438176779120029?= Orphan file may be in the recover list already when the ip_next_orphan is NULL (for example, orphan file is second tail elementof recover list). In this scenario, the file could be added to the list twice and infinite loop happened. So we need another pointer value here(EFAULT) instead of NULL for the list tail element. Signed-off-by: lihongweizz --- fs/ocfs2/journal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 126671e..4620013 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -2207,7 +2207,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, enum ocfs2_orphan_reco_type orphan_reco_type) { int ret = 0; - struct inode *inode = NULL; + struct inode *inode = ERR_PTR(-EFAULT); struct inode *iter; struct ocfs2_inode_info *oi; struct buffer_head *di_bh = NULL; @@ -2224,7 +2224,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, if (ret) mlog_errno(ret); - while (inode) { + while (!IS_ERR(inode)) { oi = OCFS2_I(inode); trace_ocfs2_recover_orphans_iput( (unsigned long long)oi->ip_blkno);