Skip to content

Commit 7705950

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: 5f2aa075070c ("exfat: add inode operations") Reported-by: Markus Elfring <Markus.Elfring@web.de> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
1 parent 3eff71e commit 7705950

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

namei.c

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

11851185
epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh,
11861186
&sector_old);
1187+
if (!epold)
1188+
return -EIO;
11871189
epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh,
11881190
&sector_new);
1189-
if (!epold || !epnew)
1191+
if (!epnew) {
1192+
brelse(old_bh);
11901193
return -EIO;
1194+
}
11911195

11921196
memcpy(epnew, epold, DENTRY_SIZE);
11931197
exfat_update_bh(sb, new_bh, sync);
@@ -1268,10 +1272,14 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
12681272

12691273
epmov = exfat_get_dentry(sb, p_olddir, oldentry + 1, &mov_bh,
12701274
&sector_mov);
1275+
if (!epmov)
1276+
return -EIO;
12711277
epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh,
12721278
&sector_new);
1273-
if (!epmov || !epnew)
1279+
if (!epnew) {
1280+
brelse(mov_bh);
12741281
return -EIO;
1282+
}
12751283

12761284
memcpy(epnew, epmov, DENTRY_SIZE);
12771285
exfat_update_bh(sb, new_bh, IS_DIRSYNC(inode));

0 commit comments

Comments
 (0)