From nobody Sun Apr 5 13:04:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49B1932BF44; Fri, 3 Apr 2026 08:06:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203610; cv=none; b=Oq9LGf/qDSMTr8ck8iHnuxoT4qBowHXOCyq0hvl2W6icTgmqy3Lng45+jjsozNF8FOnpzaMX8K7y4fhpRn+MtvptycVPoNHvfxo08VVZaqgS6CN4oRBH11OXgW8Dj27ZeY8HEZksZszrF6Ioxpd5qRyo1FtGtvJHqxcLAqi9uwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203610; c=relaxed/simple; bh=F/CDL8VyW0CX692DhFTu9Yr6yXj1cBGRo9UaLvxTghQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VXA7W3q/c72IdBwffB9QR5aDajGbaqd0vzX3f+dewYjCyBKlDF7szmyqPGVkc6DGMosKNwsXvL4qPqE4LrT4WUDR3jiJROj+jVOoZacSusD3JjUtL1jLREexZdTGHYq3bem7Biil5BdQ7RAH0sTuZdmdtiTbRdS7CtaVRJmdEJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=Vo59ozcG; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="Vo59ozcG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=x0 ZM9XluUnOwhkGJ9K+nXa5Rb6HeAXFfDwK1fCdCig0=; b=Vo59ozcGXnjyAV1HRa W4LpcP6FITe/FPEVzWH/axos6ZVZZL7WOJQWBzoKmH6eIL/Xb3eBInoQIcmn1N/n fQ59gP9u/zOR6L6tp2kgenVf8E3wj2oQ1pRkDYJko4P0Uo7uUzNDQb77GKpbyzm0 e/REg4ARQr0uRHMlBXcXGs374= Received: from czl-ubuntu-pc.. (unknown []) by gzga-smtp-mtada-g0-1 (Coremail) with SMTP id _____wDHW13+dM9pkhS7Cw--.58982S3; Fri, 03 Apr 2026 16:06:26 +0800 (CST) From: Chi Zhiling To: Namjae Jeon , Sungjong Seo , Yuezhang Mo Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Chi Zhiling Subject: [PATCH v3 1/6] exfat: fix incorrect directory checksum after rename to shorter name Date: Fri, 3 Apr 2026 16:05:33 +0800 Message-ID: <20260403080538.361663-2-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260403080538.361663-1-chizhiling@163.com> References: <20260403080538.361663-1-chizhiling@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDHW13+dM9pkhS7Cw--.58982S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xr1DKF15uF15Ww13CF47twb_yoWkurX_ua yrtr1DKryYyFn8JwsxKF1rGr1Sga18ur15JrnYvFnxWas3tF9xXw1DCrnFv3W7tw4rKr98 CrykWr1qka1rtjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8EtC7UUUUU== X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbC3AKrSWnPdQLy0QAA3O Content-Type: text/plain; charset="utf-8" From: Chi Zhiling When renaming a file in-place to a shorter name, exfat_remove_entries marks excess entries as DELETED, but es->num_entries is not updated accordingly. As a result, exfat_update_dir_chksum iterates over the deleted entries and computes an incorrect checksum. This does not lead to persistent corruption because mark_inode_dirty() is called afterward, and __exfat_write_inode later recomputes the checksum using the correct num_entries value. Fix by setting es->num_entries =3D num_entries in exfat_init_ext_entry. Signed-off-by: Chi Zhiling Reviewed-by: Sungjong Seo --- fs/exfat/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index a2c2b998808c..7619410d668e 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -490,6 +490,7 @@ void exfat_init_ext_entry(struct exfat_entry_set_cache = *es, int num_entries, unsigned short *uniname =3D p_uniname->name; struct exfat_dentry *ep; =20 + es->num_entries =3D num_entries; ep =3D exfat_get_dentry_cached(es, ES_IDX_FILE); ep->dentry.file.num_ext =3D (unsigned char)(num_entries - 1); =20 --=20 2.43.0 From nobody Sun Apr 5 13:04:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D433311C32; Fri, 3 Apr 2026 08:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203609; cv=none; b=LYtskXpluZ/wxJuC10H6UsqRPTcgG8qQyzHXBAVAVVI6Mom0ZIbvttquKXdD/adLr3jQzQF8T8sO3lCzeOOXvlBfaudFiFEh2qeRccxPHC82dES07kQZqzcuTCjhxTcpcmVwClQH817TAO3m3npahBNPOXpA7fkPuOVYqNS8SL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203609; c=relaxed/simple; bh=qvyE7fTPW9hxsAsIdDB7RsZ5byNvzlfUqZdV6FrH0rM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DQRfTbsOswSLQlI5Ehw6OY/tmSpwadgObcwL/Ri1L3+2ma1/xtFLEA2vXh9FhZP/tlKnoBlu6TWlXoxBBbkOxjNjpR1XzPhQjYaNZ9cGLY1TcXjsUtm4/Z0a2dMQiI1zWMpKy4LZSmJTB73hl1QgSa4GoUY0rh14V2qXHE6J1aM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=EnL8LkiJ; arc=none smtp.client-ip=220.197.31.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="EnL8LkiJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=g3 HWHWKBHXYVZdwbLJwhaJIwsvsTJkC9MBeECTg9tRo=; b=EnL8LkiJBU8KUDXeYC KrDSeiHwIHtGAiAKrcixbPdjOwRCxgJCxv5CsyiR6F0XMmAeM80CNmnk3yKK1Sl9 1/gLZPd9UzLnqHSxVhUbeiVNvGd2YI1LkAT+V8C4RlcidT2cRmGgGxnq78mNPpmW jYOST2zeE4lWL6jLbakyUQVfo= Received: from czl-ubuntu-pc.. (unknown []) by gzga-smtp-mtada-g0-1 (Coremail) with SMTP id _____wDHW13+dM9pkhS7Cw--.58982S4; Fri, 03 Apr 2026 16:06:26 +0800 (CST) From: Chi Zhiling To: Namjae Jeon , Sungjong Seo , Yuezhang Mo Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Chi Zhiling Subject: [PATCH v3 2/6] exfat: introduce exfat_cluster_walk helper Date: Fri, 3 Apr 2026 16:05:34 +0800 Message-ID: <20260403080538.361663-3-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260403080538.361663-1-chizhiling@163.com> References: <20260403080538.361663-1-chizhiling@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDHW13+dM9pkhS7Cw--.58982S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7CrykuryDGF47ur4xWw45Jrb_yoW8AF1rpF 4UGayrJrW5Wa47u3WfJrs3uF4a9ws7GFykArWxuwn0yrZ8tFyv9F98KryYyF1I9w40g3WY gF4Ygr18urnxGFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jwGYLUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbC+AKrSWnPdQK4SAAA35 Content-Type: text/plain; charset="utf-8" From: Chi Zhiling Introduce exfat_cluster_walk() to walk the FAT chain by a given step, handling both ALLOC_NO_FAT_CHAIN and ALLOC_FAT_CHAIN modes. Also redefine exfat_get_next_cluster as a thin wrapper around it for backward compatibility. Signed-off-by: Chi Zhiling Reviewed-by: Sungjong Seo --- fs/exfat/exfat_fs.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 9fed9fb33cae..7f9d0cfa252b 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -437,7 +437,8 @@ int exfat_set_volume_dirty(struct super_block *sb); int exfat_clear_volume_dirty(struct super_block *sb); =20 /* fatent.c */ -#define exfat_get_next_cluster(sb, pclu) exfat_ent_get(sb, *(pclu), pclu, = NULL) +#define exfat_get_next_cluster(sb, pclu) \ + exfat_cluster_walk(sb, (pclu), 1, ALLOC_FAT_CHAIN) =20 int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, struct exfat_chain *p_chain, bool sync_bmap); @@ -456,6 +457,26 @@ int exfat_count_num_clusters(struct super_block *sb, int exfat_blk_readahead(struct super_block *sb, sector_t sec, sector_t *ra, blkcnt_t *ra_cnt, sector_t end); =20 +static inline int +exfat_cluster_walk(struct super_block *sb, unsigned int *clu, + unsigned int step, int flags) +{ + struct buffer_head *bh =3D NULL; + + if (flags =3D=3D ALLOC_NO_FAT_CHAIN) { + (*clu) +=3D step; + return 0; + } + + while (step--) { + if (exfat_ent_get(sb, *clu, clu, &bh)) + return -EIO; + } + brelse(bh); + + return 0; +} + /* balloc.c */ int exfat_load_bitmap(struct super_block *sb); void exfat_free_bitmap(struct exfat_sb_info *sbi); --=20 2.43.0 From nobody Sun Apr 5 13:04:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2A7132C937; Fri, 3 Apr 2026 08:06:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203621; cv=none; b=R2sclsErh5+TJ3ERl4Ukoh/OqS+nXDchL6flx6+RU/3gcT38ueli9dkyglYQZxk5jkWjsPcE7m6Td9Z9TkOPsPdHudvckpp6lD6y+hguWhG7o2YB2o6ggNPM4tEAvlXOe6sH8D7+46AdO4rRHkrOwUbwMnuyGyxX6fewjklrsRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203621; c=relaxed/simple; bh=jqT45xLKQTInKV1ClycTE9qO/pcNFb7Vg9bW3BhvA+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tIQgVEqpXL3hY5+ZfojLtpqoHtFLzKqrKbb4t7LmMWSeBDwYCsen+iQb3jKm2PYg1hurdLUDPm/WC6dYZdF/RHme/CdfSumzMgVzuk+zkDhp42DDZzWsW9Jp3uXnNFLHZKGhakxrJ10G7Np0CIs/eUWCjoEIYSF/k+kaO45uWP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=Bh/EmoeM; arc=none smtp.client-ip=117.135.210.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="Bh/EmoeM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Se KkiVMXCoTVIiiAV5FG1qskkS7mt5L1Inv6oD9cdrw=; b=Bh/EmoeMPr6I8M8OMD h/QyJ3klJ5GNRMuE82H6peGpu8njLfDTzeJkagV2qrwbrLFC3aiA4R5a5F5ATun2 gqr3XxPvwCFM7Edp5j4cP7Cl8rZQKLoe3mdTnB+rn9N6kQjaW2LOR0UXxImHsakS jvShLFOgHnPeM9744wpEsUzGU= Received: from czl-ubuntu-pc.. (unknown []) by gzga-smtp-mtada-g0-1 (Coremail) with SMTP id _____wDHW13+dM9pkhS7Cw--.58982S5; Fri, 03 Apr 2026 16:06:26 +0800 (CST) From: Chi Zhiling To: Namjae Jeon , Sungjong Seo , Yuezhang Mo Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Chi Zhiling Subject: [PATCH v3 3/6] exfat: use exfat_cluster_walk helper Date: Fri, 3 Apr 2026 16:05:35 +0800 Message-ID: <20260403080538.361663-4-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260403080538.361663-1-chizhiling@163.com> References: <20260403080538.361663-1-chizhiling@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDHW13+dM9pkhS7Cw--.58982S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr1xtry8GrW8tFW3Aw45trb_yoW5uw1fpr 43Ka93tryrXayDWr4rtF4kZ3WS9ws7KFWkGrWxWw1xtF90vr10ka4Dtryxt34kG3y09FW5 tF15Kr1Uu3ZxWF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jT6wAUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbC2wKrSWnPdQL4sgAA3g Content-Type: text/plain; charset="utf-8" From: Chi Zhiling Replace the custom exfat_walk_fat_chain() function and open-coded FAT chain walking logic with the exfat_cluster_walk() helper across exfat_find_location, __exfat_get_dentry_set, and exfat_map_cluster. Suggested-by: Sungjong Seo Signed-off-by: Chi Zhiling Reviewed-by: Sungjong Seo --- fs/exfat/dir.c | 47 +++++++++++------------------------------------ fs/exfat/inode.c | 11 ++--------- 2 files changed, 13 insertions(+), 45 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 7619410d668e..ca5827046a1f 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -562,38 +562,6 @@ int exfat_put_dentry_set(struct exfat_entry_set_cache = *es, int sync) return err; } =20 -static int exfat_walk_fat_chain(struct super_block *sb, - struct exfat_chain *p_dir, unsigned int byte_offset, - unsigned int *clu) -{ - struct exfat_sb_info *sbi =3D EXFAT_SB(sb); - unsigned int clu_offset; - unsigned int cur_clu; - - clu_offset =3D EXFAT_B_TO_CLU(byte_offset, sbi); - cur_clu =3D p_dir->dir; - - if (p_dir->flags =3D=3D ALLOC_NO_FAT_CHAIN) { - cur_clu +=3D clu_offset; - } else { - while (clu_offset > 0) { - if (exfat_get_next_cluster(sb, &cur_clu)) - return -EIO; - if (cur_clu =3D=3D EXFAT_EOF_CLUSTER) { - exfat_fs_error(sb, - "invalid dentry access beyond EOF (clu : %u, eidx : %d)", - p_dir->dir, - EXFAT_B_TO_DEN(byte_offset)); - return -EIO; - } - clu_offset--; - } - } - - *clu =3D cur_clu; - return 0; -} - static int exfat_find_location(struct super_block *sb, struct exfat_chain = *p_dir, int entry, sector_t *sector, int *offset) { @@ -603,10 +571,19 @@ static int exfat_find_location(struct super_block *sb= , struct exfat_chain *p_dir =20 off =3D EXFAT_DEN_TO_B(entry); =20 - ret =3D exfat_walk_fat_chain(sb, p_dir, off, &clu); + clu =3D p_dir->dir; + ret =3D exfat_cluster_walk(sb, &clu, EXFAT_B_TO_CLU(off, sbi), p_dir->fla= gs); if (ret) return ret; =20 + if (clu =3D=3D EXFAT_EOF_CLUSTER) { + exfat_fs_error(sb, + "unexpected early break in cluster chain (clu : %u, len : %d)", + p_dir->dir, + EXFAT_B_TO_CLU(off, sbi)); + return -EIO; + } + if (!exfat_test_bitmap(sb, clu)) { exfat_err(sb, "failed to test cluster bit(%u)", clu); return -EIO; @@ -792,9 +769,7 @@ static int __exfat_get_dentry_set(struct exfat_entry_se= t_cache *es, if (exfat_is_last_sector_in_cluster(sbi, sec)) { unsigned int clu =3D exfat_sector_to_cluster(sbi, sec); =20 - if (p_dir->flags =3D=3D ALLOC_NO_FAT_CHAIN) - clu++; - else if (exfat_get_next_cluster(sb, &clu)) + if (exfat_cluster_walk(sb, &clu, 1, p_dir->flags)) goto put_es; sec =3D exfat_cluster_to_sector(sbi, clu); } else { diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index beb9ea7cca9f..cde2eb0f31ad 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -225,15 +225,8 @@ static int exfat_map_cluster(struct inode *inode, unsi= gned int clu_offset, * *clu =3D (the first cluster of the allocated chain) =3D> * (the last cluster of ...) */ - if (ei->flags =3D=3D ALLOC_NO_FAT_CHAIN) { - *clu +=3D num_to_be_allocated - 1; - } else { - while (num_to_be_allocated > 1) { - if (exfat_get_next_cluster(sb, clu)) - return -EIO; - num_to_be_allocated--; - } - } + if (exfat_cluster_walk(sb, clu, num_to_be_allocated - 1, ei->flags)) + return -EIO; *count =3D 1; } =20 --=20 2.43.0 From nobody Sun Apr 5 13:04:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C39DE33F8C1; Fri, 3 Apr 2026 08:06:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203621; cv=none; b=tu0R5bmOBhDdEnNVlwInBSQCDrqEdeRjBl+au6cN27+Q/VhiDQ58hsmdHu8GC56Z0D1IbI92RPqNbNqD0cTSo7IqDrGYGljUQWUxRxEiiSLa4ugpjW+VXakE5XtJSQRrNJDf5R7z9RiWUtgE3fLNs2pi3CDJ6JUfCcLinCX87fk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203621; c=relaxed/simple; bh=Hzi7QI0MjFR+00hDT1WJfqj2/XOv4/m9Z99ISdI3jp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kTet8xiFIuyZzEh24/GCIE/udnInsC6Le2c9RcCvmvqGPUbRvd6Li4BWm4c/fu50/P8GWmhaN/e/iwbg7vHogb+ppjJAFOiYk5uL7DG0+UhEuX6vKBCrvooPT8gV9opjzIjDz7kh2TTZRgOFrvmY/YMVXohYibZIpc5zT6RFr98= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=DXL9gSWv; arc=none smtp.client-ip=220.197.31.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="DXL9gSWv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=n6 bPhhXb8I2/V20ZXRI8m7mImL5UZIwvzwNnhJkmkM8=; b=DXL9gSWvIzQhJilfn5 qxfQhjHZQ3giwQET7+n7C3qENDFBa5AEldSW7uUHfDaylCouA0WstV6gF1aVcvRO 5eGbZrIZTSMjNkcsGaYc1LcH43AbfVc5aWzn6Rqt8LxYWUFzCBkNzET58w24zTbq +saInDQgzje/nVrJ0CABj6jk8= Received: from czl-ubuntu-pc.. (unknown []) by gzga-smtp-mtada-g0-1 (Coremail) with SMTP id _____wDHW13+dM9pkhS7Cw--.58982S6; Fri, 03 Apr 2026 16:06:26 +0800 (CST) From: Chi Zhiling To: Namjae Jeon , Sungjong Seo , Yuezhang Mo Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Chi Zhiling Subject: [PATCH v3 4/6] exfat: remove NULL cache pointer case in exfat_ent_get Date: Fri, 3 Apr 2026 16:05:36 +0800 Message-ID: <20260403080538.361663-5-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260403080538.361663-1-chizhiling@163.com> References: <20260403080538.361663-1-chizhiling@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDHW13+dM9pkhS7Cw--.58982S6 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ww4kCw43tw17trWrKr47twb_yoW8KFWDpr ZIka97tr4Ut3ZF93ZFyrs3Z3WfC397JFykGa1rCF93Ar1UtFn5XFyxtFyFyF48Ca97uFWY vF4UKF15C3srWaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j2ZXOUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbC9wKrSWnPdQKwMgAA3E Content-Type: text/plain; charset="utf-8" From: Chi Zhiling Since exfat_get_next_cluster has been updated, no callers pass a NULL pointer to exfat_ent_get, so remove the handling logic for this case. Signed-off-by: Chi Zhiling Reviewed-by: Sungjong Seo --- fs/exfat/fatent.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index f2e5d5dde393..dce0955e689a 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -44,11 +44,11 @@ static int exfat_end_bh(struct super_block *sb, struct = buffer_head *bh) } =20 static int __exfat_ent_get(struct super_block *sb, unsigned int loc, - unsigned int *content, struct buffer_head **last) + unsigned int *content, struct buffer_head **cache) { unsigned int off; sector_t sec; - struct buffer_head *bh =3D last ? *last : NULL; + struct buffer_head *bh =3D *cache; =20 sec =3D FAT_ENT_OFFSET_SECTOR(sb, loc); off =3D FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc); @@ -56,8 +56,7 @@ static int __exfat_ent_get(struct super_block *sb, unsign= ed int loc, if (!bh || bh->b_blocknr !=3D sec || !buffer_uptodate(bh)) { brelse(bh); bh =3D sb_bread(sb, sec); - if (last) - *last =3D bh; + *cache =3D bh; if (unlikely(!bh)) return -EIO; } @@ -68,8 +67,6 @@ static int __exfat_ent_get(struct super_block *sb, unsign= ed int loc, if (*content > EXFAT_BAD_CLUSTER) *content =3D EXFAT_EOF_CLUSTER; =20 - if (!last) - brelse(bh); return 0; } =20 @@ -111,7 +108,7 @@ int exfat_ent_set(struct super_block *sb, unsigned int = loc, * Caller must release the buffer_head if no error return. */ int exfat_ent_get(struct super_block *sb, unsigned int loc, - unsigned int *content, struct buffer_head **last) + unsigned int *content, struct buffer_head **cache) { struct exfat_sb_info *sbi =3D EXFAT_SB(sb); =20 @@ -122,7 +119,7 @@ int exfat_ent_get(struct super_block *sb, unsigned int = loc, goto err; } =20 - if (unlikely(__exfat_ent_get(sb, loc, content, last))) { + if (unlikely(__exfat_ent_get(sb, loc, content, cache))) { exfat_fs_error_ratelimit(sb, "failed to access to FAT (entry 0x%08x)", loc); @@ -151,13 +148,11 @@ int exfat_ent_get(struct super_block *sb, unsigned in= t loc, } =20 return 0; -err: - if (last) { - brelse(*last); =20 - /* Avoid double release */ - *last =3D NULL; - } +err: + /* Avoid double release */ + brelse(*cache); + *cache =3D NULL; return -EIO; } =20 --=20 2.43.0 From nobody Sun Apr 5 13:04:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3094D32D0CF; Fri, 3 Apr 2026 08:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203631; cv=none; b=kD6FlpxuUHSY76b2Jkn2643Ul+sgpHjJw9XJ+ogBaN6SEQyaDcYxTL450/sZ6oN7NWAdC1s1ayrRICre2ILI1oYwGCseelmhU6/NaDV58LOtJcA833Mgmy6ibVWwXFzcBbyI4zzqFDxsvtMwc9sttC3SxE1mZICMGk8IVP13IQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203631; c=relaxed/simple; bh=tkbRZQimK5gE+e9gmKDANAnzEdWXdVJmz4K7IwG1n0Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k+3beQ1/N3ICJIELZx1NRf2FI2wZqQ1RauNWjAyggk2I4paH5I0H/Dz2YtesvTC0esTiw6NiShYAypiSSgzB/xCSyBWtwYBf0lRoKNPuLUXDIrE6BOy+rWVrUUKvhVO4OCnHAawtaIx9Ve0lOEq4dkjLNRIkieGhfPFxWLAuM+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=cLfft+xv; arc=none smtp.client-ip=117.135.210.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="cLfft+xv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Xy fsN/JWMj7HEIjC10PHq0KzFD0yep39q536Og73j8g=; b=cLfft+xvQc8MURzIpR P3nV0i94pP/3O+DgwlaLT1WhqiT3RSCAcW3uouRmgJxUoRHaNWRPUxIyflcdUE/H eTxZAHfbWdWHjmmppvqLNhUmX2hbkAvU5t44fSay1xcgKyU7+xRQq/lKzxId8CdQ +aowyFepWd2DY9/nk72jaj+6A= Received: from czl-ubuntu-pc.. (unknown []) by gzga-smtp-mtada-g0-1 (Coremail) with SMTP id _____wDHW13+dM9pkhS7Cw--.58982S7; Fri, 03 Apr 2026 16:06:27 +0800 (CST) From: Chi Zhiling To: Namjae Jeon , Sungjong Seo , Yuezhang Mo Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Chi Zhiling , syzbot@syzkaller.appspotmail.com, Yuezhang Mo Subject: [PATCH v3 5/6] exfat: introduce exfat_chain_advance helper Date: Fri, 3 Apr 2026 16:05:37 +0800 Message-ID: <20260403080538.361663-6-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260403080538.361663-1-chizhiling@163.com> References: <20260403080538.361663-1-chizhiling@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDHW13+dM9pkhS7Cw--.58982S7 X-Coremail-Antispam: 1Uf129KBjvJXoW7WryxXw18uF4xGFW3GFy8Xwb_yoW8Xr4DpF 47Ga15J3yjqa4xu3WfJr43Xa4Y9wn7GFWkJrWxZw1Yyrn0qryvkF93Kry29Fyrt3y0k3W2 v3WYgr1j9wsxGFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UKXd8UUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbC9wOrSWnPdQOwQgAA30 Content-Type: text/plain; charset="utf-8" From: Chi Zhiling Introduce exfat_chain_advance() to walk a exfat_chain structure by a given step, updating both ->dir and ->size fields atomically. This helper handles both ALLOC_NO_FAT_CHAIN and ALLOC_FAT_CHAIN modes with proper boundary checking. Tested-by: syzbot@syzkaller.appspotmail.com Suggested-by: Yuezhang Mo Signed-off-by: Chi Zhiling Reviewed-by: Sungjong Seo --- fs/exfat/exfat_fs.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 7f9d0cfa252b..89ef5368277f 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -552,6 +552,27 @@ int exfat_read_volume_label(struct super_block *sb, int exfat_write_volume_label(struct super_block *sb, struct exfat_uni_name *label); =20 +static inline int exfat_chain_advance(struct super_block *sb, + struct exfat_chain *chain, unsigned int step) +{ + unsigned int clu =3D chain->dir; + + if (unlikely(chain->size < step)) + return -EIO; + + if (exfat_cluster_walk(sb, &clu, step, chain->flags)) + return -EIO; + + chain->size -=3D step; + + if (chain->size =3D=3D 0 && chain->flags =3D=3D ALLOC_NO_FAT_CHAIN) + chain->dir =3D EXFAT_EOF_CLUSTER; + else + chain->dir =3D clu; + + return 0; +} + /* inode.c */ extern const struct inode_operations exfat_file_inode_operations; void exfat_sync_inode(struct inode *inode); --=20 2.43.0 From nobody Sun Apr 5 13:04:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1825311C32; Fri, 3 Apr 2026 08:06:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203622; cv=none; b=JsanMDZbEDJHVOzIMrm+VXlWHt/88TqB0+YTeMeSI0A4H9YNVirZn1agoFbgPIrtF2+ssbPI7hfEVx2M+uKaOEokq1sJp31wOsspSl84VFQYXShiuTsQbrumGJtx4wZS5FPzxuGJoVC/axhCZvfT0UWuFQYXcub55d1Z52Tvm2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775203622; c=relaxed/simple; bh=oeZOKBE1VUbPdhRxvr7y7onYWsDHmOHJYC/N/JXksYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iq+IaLUjgpZnxA5yMVDRVYoLXNiewFtX1VBnHI/Pe+23ahz4We/Wqhwldyztx2lNrfqRfzIMzyafnkp6klqFVPdz7tYmHsv5FT4nlOCepcqKi9Uvsl5fNVT6WKhll133kVGmjNdKqDtn1856At8fGTz+aracUDWO9TLGaz8Dknc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=jas2XIpT; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="jas2XIpT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=ow mM8/gIcl1tt6ElQgY8wj/vutoa/bCpaIzHu7o+Pmo=; b=jas2XIpTI+HC0LjdlW lvcQIRBQEY1c1pEe1zzxPbAyyLvrbgdDd+rdH6WAsrnvorHKKx+igoRGJWmg3ODS k5rpZWXRuoKGuea0WZnQUbPHeLv0d9Wi7uADkba8hKZiOaeK1tj16WnHO+by+3vN NzEiCI11thzY0xzO/VHQB13so= Received: from czl-ubuntu-pc.. (unknown []) by gzga-smtp-mtada-g0-1 (Coremail) with SMTP id _____wDHW13+dM9pkhS7Cw--.58982S8; Fri, 03 Apr 2026 16:06:27 +0800 (CST) From: Chi Zhiling To: Namjae Jeon , Sungjong Seo , Yuezhang Mo Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Chi Zhiling Subject: [PATCH v3 6/6] exfat: use exfat_chain_advance helper Date: Fri, 3 Apr 2026 16:05:38 +0800 Message-ID: <20260403080538.361663-7-chizhiling@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260403080538.361663-1-chizhiling@163.com> References: <20260403080538.361663-1-chizhiling@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDHW13+dM9pkhS7Cw--.58982S8 X-Coremail-Antispam: 1Uf129KBjvJXoWxCry8CrWrZw47XFWUGr4xtFb_yoW7Jr17pF 47Ga93JFyDJayqk3W8t3ZFva4Y9ws3GFyUXFn7uw1F9rZFyr1rC3s7CryIqF95C395Zw12 qw1Utr1jgFsxWFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07URHqxUUUUU= X-CM-SenderInfo: hfkl6xxlol0wi6rwjhhfrp/xtbC+AOrSWnPdQO4YgAA3T Content-Type: text/plain; charset="utf-8" From: Chi Zhiling Replace open-coded cluster chain walking logic with exfat_chain_advance() across exfat_readdir, exfat_find_dir_entry, exfat_count_dir_entries, exfat_search_empty_slot and exfat_check_dir_empty. Signed-off-by: Chi Zhiling Reviewed-by: Sungjong Seo --- fs/exfat/dir.c | 71 ++++++++++++------------------------------------ fs/exfat/namei.c | 28 +++++-------------- 2 files changed, 25 insertions(+), 74 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index ca5827046a1f..ac008ccaa97d 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -93,25 +93,19 @@ static int exfat_readdir(struct inode *inode, loff_t *c= pos, struct exfat_dir_ent clu_offset =3D EXFAT_DEN_TO_CLU(dentry, sbi); exfat_chain_dup(&clu, &dir); =20 - if (clu.flags =3D=3D ALLOC_NO_FAT_CHAIN) { - clu.dir +=3D clu_offset; - clu.size -=3D clu_offset; - } else { + if (clu.flags =3D=3D ALLOC_FAT_CHAIN) { /* hint_information */ if (clu_offset > 0 && ei->hint_bmap.off !=3D EXFAT_EOF_CLUSTER && ei->hint_bmap.off > 0 && clu_offset >=3D ei->hint_bmap.off) { clu_offset -=3D ei->hint_bmap.off; clu.dir =3D ei->hint_bmap.clu; - } - - while (clu_offset > 0 && clu.dir !=3D EXFAT_EOF_CLUSTER) { - if (exfat_get_next_cluster(sb, &(clu.dir))) - return -EIO; - - clu_offset--; + clu.size -=3D ei->hint_bmap.off; } } =20 + if (exfat_chain_advance(sb, &clu, clu_offset)) + return -EIO; + while (clu.dir !=3D EXFAT_EOF_CLUSTER && dentry < max_dentries) { i =3D dentry & (dentries_per_clu - 1); =20 @@ -160,15 +154,8 @@ static int exfat_readdir(struct inode *inode, loff_t *= cpos, struct exfat_dir_ent return 0; } =20 - if (clu.flags =3D=3D ALLOC_NO_FAT_CHAIN) { - if (--clu.size > 0) - clu.dir++; - else - clu.dir =3D EXFAT_EOF_CLUSTER; - } else { - if (exfat_get_next_cluster(sb, &(clu.dir))) - return -EIO; - } + if (exfat_chain_advance(sb, &clu, 1)) + return -EIO; } =20 out: @@ -1085,19 +1072,12 @@ int exfat_find_dir_entry(struct super_block *sb, st= ruct exfat_inode_info *ei, step =3D DIRENT_STEP_FILE; } =20 - if (clu.flags =3D=3D ALLOC_NO_FAT_CHAIN) { - if (--clu.size > 0) - clu.dir++; - else - clu.dir =3D EXFAT_EOF_CLUSTER; - } else { - if (exfat_get_next_cluster(sb, &clu.dir)) - return -EIO; + if (exfat_chain_advance(sb, &clu, 1)) + return -EIO; =20 - /* break if the cluster chain includes a loop */ - if (unlikely(++clu_count > EXFAT_DATA_CLUSTER_COUNT(sbi))) - goto not_found; - } + /* break if the cluster chain includes a loop */ + if (unlikely(++clu_count > EXFAT_DATA_CLUSTER_COUNT(sbi))) + goto not_found; } =20 not_found: @@ -1132,14 +1112,7 @@ int exfat_find_dir_entry(struct super_block *sb, str= uct exfat_inode_info *ei, if (!((dentry + 1) & (dentries_per_clu - 1))) { int ret =3D 0; =20 - if (clu.flags =3D=3D ALLOC_NO_FAT_CHAIN) { - if (--clu.size > 0) - clu.dir++; - else - clu.dir =3D EXFAT_EOF_CLUSTER; - } else { - ret =3D exfat_get_next_cluster(sb, &clu.dir); - } + ret =3D exfat_chain_advance(sb, &clu, 1); =20 if (ret || clu.dir =3D=3D EXFAT_EOF_CLUSTER) { /* just initialized hint_stat */ @@ -1184,20 +1157,12 @@ int exfat_count_dir_entries(struct super_block *sb,= struct exfat_chain *p_dir) count++; } =20 - if (clu.flags =3D=3D ALLOC_NO_FAT_CHAIN) { - if (--clu.size > 0) - clu.dir++; - else - clu.dir =3D EXFAT_EOF_CLUSTER; - } else { - if (exfat_get_next_cluster(sb, &(clu.dir))) - return -EIO; - - if (unlikely(++clu_count > sbi->used_clusters)) { - exfat_fs_error(sb, "FAT or bitmap is corrupted"); - return -EIO; - } + if (exfat_chain_advance(sb, &clu, 1)) + return -EIO; =20 + if (unlikely(++clu_count > sbi->used_clusters)) { + exfat_fs_error(sb, "FAT or bitmap is corrupted"); + return -EIO; } } =20 diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index d0ea1ff81c09..2c5636634b4a 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -246,15 +246,8 @@ static int exfat_search_empty_slot(struct super_block = *sb, i +=3D ret; =20 while (i >=3D dentries_per_clu) { - if (clu.flags =3D=3D ALLOC_NO_FAT_CHAIN) { - if (--clu.size > 0) - clu.dir++; - else - clu.dir =3D EXFAT_EOF_CLUSTER; - } else { - if (exfat_get_next_cluster(sb, &clu.dir)) - return -EIO; - } + if (exfat_chain_advance(sb, &clu, 1)) + return -EIO; =20 i -=3D dentries_per_clu; } @@ -925,19 +918,12 @@ static int exfat_check_dir_empty(struct super_block *= sb, return -ENOTEMPTY; } =20 - if (clu.flags =3D=3D ALLOC_NO_FAT_CHAIN) { - if (--clu.size > 0) - clu.dir++; - else - clu.dir =3D EXFAT_EOF_CLUSTER; - } else { - if (exfat_get_next_cluster(sb, &(clu.dir))) - return -EIO; + if (exfat_chain_advance(sb, &clu, 1)) + return -EIO; =20 - /* break if the cluster chain includes a loop */ - if (unlikely(++clu_count > EXFAT_DATA_CLUSTER_COUNT(sbi))) - break; - } + /* break if the cluster chain includes a loop */ + if (unlikely(++clu_count > EXFAT_DATA_CLUSTER_COUNT(sbi))) + break; } =20 return 0; --=20 2.43.0