Skip to content

Commit e8dd3cd

Browse files
Dan Carpenternamjaejeon
authored andcommitted
exfat: add missing brelse() calls on error paths
If the second exfat_get_dentry() call fails then we need to release "old_bh" before returning. There is a similar bug in exfat_move_file(). Fixes: 5f2aa07 ("exfat: add inode operations") Reported-by: Markus Elfring <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 4ba6ccd commit e8dd3cd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fs/exfat/namei.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,10 +1077,14 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
10771077

10781078
epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh,
10791079
&sector_old);
1080+
if (!epold)
1081+
return -EIO;
10801082
epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh,
10811083
&sector_new);
1082-
if (!epold || !epnew)
1084+
if (!epnew) {
1085+
brelse(old_bh);
10831086
return -EIO;
1087+
}
10841088

10851089
memcpy(epnew, epold, DENTRY_SIZE);
10861090
exfat_update_bh(sb, new_bh, sync);
@@ -1161,10 +1165,14 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
11611165

11621166
epmov = exfat_get_dentry(sb, p_olddir, oldentry + 1, &mov_bh,
11631167
&sector_mov);
1168+
if (!epmov)
1169+
return -EIO;
11641170
epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh,
11651171
&sector_new);
1166-
if (!epmov || !epnew)
1172+
if (!epnew) {
1173+
brelse(mov_bh);
11671174
return -EIO;
1175+
}
11681176

11691177
memcpy(epnew, epmov, DENTRY_SIZE);
11701178
exfat_update_bh(sb, new_bh, IS_DIRSYNC(inode));

0 commit comments

Comments
 (0)