From: Yuezhang Mo Date: Fri, 22 Nov 2024 02:50:55 +0000 (+0800) Subject: exfat: fix just enough dentries but allocate a new cluster to dir X-Git-Tag: v6.12.19~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d609f0d2fbadcbfa4c37a418ee6de994d957904;p=thirdparty%2Fkernel%2Fstable.git exfat: fix just enough dentries but allocate a new cluster to dir [ Upstream commit 6697f819a10b238ccf01998c3f203d65d8374696 ] This commit fixes the condition for allocating cluster to parent directory to avoid allocating new cluster to parent directory when there are just enough empty directory entries at the end of the parent directory. Fixes: af02c72d0b62 ("exfat: convert exfat_find_empty_entry() to use dentry cache") Signed-off-by: Yuezhang Mo Signed-off-by: Namjae Jeon Signed-off-by: Sasha Levin --- diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 337197ece5995..e47a5ddfc79b3 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -237,7 +237,7 @@ static int exfat_search_empty_slot(struct super_block *sb, dentry = 0; } - while (dentry + num_entries < total_entries && + while (dentry + num_entries <= total_entries && clu.dir != EXFAT_EOF_CLUSTER) { i = dentry & (dentries_per_clu - 1);