Commit e8dd3cda authored by Dan Carpenter's avatar Dan Carpenter Committed by Namjae Jeon

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: 5f2aa075 ("exfat: add inode operations")
Reported-by: default avatarMarkus Elfring <Markus.Elfring@web.de>
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
parent 4ba6ccd6
...@@ -1077,10 +1077,14 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, ...@@ -1077,10 +1077,14 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir,
epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh, epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh,
&sector_old); &sector_old);
if (!epold)
return -EIO;
epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh, epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh,
&sector_new); &sector_new);
if (!epold || !epnew) if (!epnew) {
brelse(old_bh);
return -EIO; return -EIO;
}
memcpy(epnew, epold, DENTRY_SIZE); memcpy(epnew, epold, DENTRY_SIZE);
exfat_update_bh(sb, new_bh, sync); exfat_update_bh(sb, new_bh, sync);
...@@ -1161,10 +1165,14 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, ...@@ -1161,10 +1165,14 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir,
epmov = exfat_get_dentry(sb, p_olddir, oldentry + 1, &mov_bh, epmov = exfat_get_dentry(sb, p_olddir, oldentry + 1, &mov_bh,
&sector_mov); &sector_mov);
if (!epmov)
return -EIO;
epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh, epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh,
&sector_new); &sector_new);
if (!epmov || !epnew) if (!epnew) {
brelse(mov_bh);
return -EIO; return -EIO;
}
memcpy(epnew, epmov, DENTRY_SIZE); memcpy(epnew, epmov, DENTRY_SIZE);
exfat_update_bh(sb, new_bh, IS_DIRSYNC(inode)); exfat_update_bh(sb, new_bh, IS_DIRSYNC(inode));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment