Skip to content

Commit 7a5e9a1

Browse files
committed
Merge tag 'exfat-for-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat
Pull exfat updates from Namjae Jeon: - Improved compatibility issue with exfat from some camera vendors. - Do not need to release root inode on error path. * tag 'exfat-for-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat: exfat: handle wrong stream entry size in exfat_readdir() exfat: avoid incorrectly releasing for root inode
2 parents 79160a6 + 1e5654d commit 7a5e9a1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

fs/exfat/dir.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb,
6363
static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_entry *dir_entry)
6464
{
6565
int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext;
66-
unsigned int type, clu_offset;
66+
unsigned int type, clu_offset, max_dentries;
6767
sector_t sector;
6868
struct exfat_chain dir, clu;
6969
struct exfat_uni_name uni_name;
@@ -86,6 +86,8 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent
8686

8787
dentries_per_clu = sbi->dentries_per_clu;
8888
dentries_per_clu_bits = ilog2(dentries_per_clu);
89+
max_dentries = (unsigned int)min_t(u64, MAX_EXFAT_DENTRIES,
90+
(u64)sbi->num_clusters << dentries_per_clu_bits);
8991

9092
clu_offset = dentry >> dentries_per_clu_bits;
9193
exfat_chain_dup(&clu, &dir);
@@ -109,7 +111,7 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent
109111
}
110112
}
111113

112-
while (clu.dir != EXFAT_EOF_CLUSTER) {
114+
while (clu.dir != EXFAT_EOF_CLUSTER && dentry < max_dentries) {
113115
i = dentry & (dentries_per_clu - 1);
114116

115117
for ( ; i < dentries_per_clu; i++, dentry++) {
@@ -245,7 +247,7 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx)
245247
if (err)
246248
goto unlock;
247249
get_new:
248-
if (cpos >= i_size_read(inode))
250+
if (ei->flags == ALLOC_NO_FAT_CHAIN && cpos >= i_size_read(inode))
249251
goto end_of_dir;
250252

251253
err = exfat_readdir(inode, &cpos, &de);

fs/exfat/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ static int exfat_fill_super(struct super_block *sb, struct fs_context *fc)
690690
if (!sb->s_root) {
691691
exfat_err(sb, "failed to get the root dentry");
692692
err = -ENOMEM;
693-
goto put_inode;
693+
goto free_table;
694694
}
695695

696696
return 0;

0 commit comments

Comments
 (0)