summaryrefslogtreecommitdiff
path: root/fs/ext2/dir.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2023-01-11 15:21:52 -0500
committerJan Kara <jack@suse.cz>2023-05-29 11:03:06 +0200
commit8f1dca19b1e11785f42e70da796942154f63aef9 (patch)
tree6f315d51bfa79b6ad434c2c607c2ccad1c96592c /fs/ext2/dir.c
parent6e335cd789bee7a7111c4fe6d46b1d63cde81511 (diff)
downloadlwn-8f1dca19b1e11785f42e70da796942154f63aef9.tar.gz
lwn-8f1dca19b1e11785f42e70da796942154f63aef9.zip
ext2_rename(): set_link and delete_entry may fail
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Tested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext2/dir.c')
-rw-r--r--fs/ext2/dir.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 4a6955a0a116..a3c77ea5a7de 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -606,8 +606,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 *dir, struct page *page,
if (de->rec_len == 0) {
ext2_error(inode->i_sb, __func__,
"zero-length directory entry");
- err = -EIO;
- goto out;
+ return -EIO;
}
pde = de;
de = ext2_next_entry(de);
@@ -617,7 +616,10 @@ int ext2_delete_entry (struct ext2_dir_entry_2 *dir, struct page *page,
pos = page_offset(page) + from;
lock_page(page);
err = ext2_prepare_chunk(page, pos, to - from);
- BUG_ON(err);
+ if (err) {
+ unlock_page(page);
+ return err;
+ }
if (pde)
pde->rec_len = ext2_rec_len_to_disk(to - from);
dir->inode = 0;
@@ -625,9 +627,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 *dir, struct page *page,
inode->i_ctime = inode->i_mtime = current_time(inode);
EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(inode);
- err = ext2_handle_dirsync(inode);
-out:
- return err;
+ return ext2_handle_dirsync(inode);
}
/*