Skip to content

Commit 8b0c471

Browse files
Tetsuhiro Kohadanamjaejeon
authored andcommitted
exfat: add error check when updating dir-entries
Add error check when synchronously updating dir-entries. Suggested-by: Sungjong Seo <[email protected]> Signed-off-by: Tetsuhiro Kohada <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 3db3c3f commit 8b0c471

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

fs/exfat/dir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es)
604604
es->modified = true;
605605
}
606606

607-
void exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
607+
int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
608608
{
609609
int i, err = 0;
610610

@@ -617,6 +617,7 @@ void exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync)
617617
else
618618
brelse(es->bh[i]);
619619
kfree(es);
620+
return err;
620621
}
621622

622623
static int exfat_walk_fat_chain(struct super_block *sb,

fs/exfat/exfat_fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ struct exfat_dentry *exfat_get_dentry_cached(struct exfat_entry_set_cache *es,
460460
int num);
461461
struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
462462
struct exfat_chain *p_dir, int entry, unsigned int type);
463-
void exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync);
463+
int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync);
464464
int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir);
465465

466466
/* inode.c */

fs/exfat/file.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
154154
struct timespec64 ts;
155155
struct exfat_dentry *ep, *ep2;
156156
struct exfat_entry_set_cache *es;
157+
int err;
157158

158159
es = exfat_get_dentry_set(sb, &(ei->dir), ei->entry,
159160
ES_ALL_ENTRIES);
@@ -188,7 +189,9 @@ int __exfat_truncate(struct inode *inode, loff_t new_size)
188189
}
189190

190191
exfat_update_dir_chksum_with_entry_set(es);
191-
exfat_free_dentry_set(es, inode_needs_sync(inode));
192+
err = exfat_free_dentry_set(es, inode_needs_sync(inode));
193+
if (err)
194+
return err;
192195
}
193196

194197
/* cut off from the FAT chain */

fs/exfat/inode.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ static int __exfat_write_inode(struct inode *inode, int sync)
7777
ep2->dentry.stream.size = ep2->dentry.stream.valid_size;
7878

7979
exfat_update_dir_chksum_with_entry_set(es);
80-
exfat_free_dentry_set(es, sync);
81-
return 0;
80+
return exfat_free_dentry_set(es, sync);
8281
}
8382

8483
int exfat_write_inode(struct inode *inode, struct writeback_control *wbc)
@@ -222,6 +221,7 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
222221
if (ei->dir.dir != DIR_DELETED && modified) {
223222
struct exfat_dentry *ep;
224223
struct exfat_entry_set_cache *es;
224+
int err;
225225

226226
es = exfat_get_dentry_set(sb, &(ei->dir), ei->entry,
227227
ES_ALL_ENTRIES);
@@ -240,8 +240,9 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
240240
ep->dentry.stream.valid_size;
241241

242242
exfat_update_dir_chksum_with_entry_set(es);
243-
exfat_free_dentry_set(es, inode_needs_sync(inode));
244-
243+
err = exfat_free_dentry_set(es, inode_needs_sync(inode));
244+
if (err)
245+
return err;
245246
} /* end of if != DIR_DELETED */
246247

247248
inode->i_blocks +=

0 commit comments

Comments
 (0)