Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

exfat: fix error handling for FAT table operations

Fix three error handling issues in FAT table operations:

1. Fix exfat_update_bh() to properly return errors from sync_dirty_buffer
2. Fix exfat_end_bh() to properly return errors from exfat_update_bh()
and exfat_mirror_bh()
3. Fix ignored return values from exfat_chain_cont_cluster() in inode.c
and namei.c

These fixes ensure that FAT table write errors are properly propagated
to the caller instead of being silently ignored.

Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

authored by

Chi Zhiling and committed by
Namjae Jeon
d1d75eaf 636bd622

+16 -10
+1 -1
fs/exfat/exfat_fs.h
··· 584 584 u8 *tz, __le16 *time, __le16 *date, u8 *time_cs); 585 585 u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type); 586 586 u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type); 587 - void exfat_update_bh(struct buffer_head *bh, int sync); 587 + int exfat_update_bh(struct buffer_head *bh, int sync); 588 588 int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync); 589 589 void exfat_chain_set(struct exfat_chain *ec, unsigned int dir, 590 590 unsigned int size, unsigned char flags);
+4 -4
fs/exfat/fatent.c
··· 25 25 if (!c_bh) 26 26 return -ENOMEM; 27 27 memcpy(c_bh->b_data, bh->b_data, sb->s_blocksize); 28 - exfat_update_bh(c_bh, sb->s_flags & SB_SYNCHRONOUS); 28 + err = exfat_update_bh(c_bh, sb->s_flags & SB_SYNCHRONOUS); 29 29 brelse(c_bh); 30 30 } 31 31 ··· 36 36 { 37 37 int err; 38 38 39 - exfat_update_bh(bh, sb->s_flags & SB_SYNCHRONOUS); 40 - err = exfat_mirror_bh(sb, bh); 39 + err = exfat_update_bh(bh, sb->s_flags & SB_SYNCHRONOUS); 40 + if (!err) 41 + err = exfat_mirror_bh(sb, bh); 41 42 brelse(bh); 42 - 43 43 return err; 44 44 } 45 45
+3 -2
fs/exfat/inode.c
··· 204 204 * so fat-chain should be synced with 205 205 * alloc-bitmap 206 206 */ 207 - exfat_chain_cont_cluster(sb, ei->start_clu, 208 - num_clusters); 207 + if (exfat_chain_cont_cluster(sb, ei->start_clu, 208 + num_clusters)) 209 + return -EIO; 209 210 ei->flags = ALLOC_FAT_CHAIN; 210 211 } 211 212 if (new_clu.flags == ALLOC_FAT_CHAIN)
+6 -2
fs/exfat/misc.c
··· 161 161 return chksum; 162 162 } 163 163 164 - void exfat_update_bh(struct buffer_head *bh, int sync) 164 + int exfat_update_bh(struct buffer_head *bh, int sync) 165 165 { 166 + int err = 0; 167 + 166 168 set_buffer_uptodate(bh); 167 169 mark_buffer_dirty(bh); 168 170 169 171 if (sync) 170 - sync_dirty_buffer(bh); 172 + err = sync_dirty_buffer(bh); 173 + 174 + return err; 171 175 } 172 176 173 177 int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync)
+2 -1
fs/exfat/namei.c
··· 365 365 /* no-fat-chain bit is disabled, 366 366 * so fat-chain should be synced with alloc-bitmap 367 367 */ 368 - exfat_chain_cont_cluster(sb, p_dir->dir, p_dir->size); 368 + if (exfat_chain_cont_cluster(sb, p_dir->dir, p_dir->size)) 369 + return -EIO; 369 370 p_dir->flags = ALLOC_FAT_CHAIN; 370 371 hint_femp.cur.flags = ALLOC_FAT_CHAIN; 371 372 }