aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorGuo Chao <yan@linux.vnet.ibm.com>2013-01-28 21:23:24 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-01-28 21:23:24 -0500
commitd5ac77730516028f3ceda825abefac9a1153b138 (patch)
treee42b54a9dd95eaca6026ea350d0a3241da6d4072 /fs/ext4
parentb06acd38a44127b382fa53e49878f7a2b70af6f2 (diff)
ext4: release buffer when checksum failed
Commit b0336e8d (ext4: calculate and verify checksums of directory leaf blocks) and commit dbe89444 (ext4: Calculate and verify checksums for htree nodes) forget to release buffer when checksum failed, at some places. Signed-off-by: Guo Chao <yan@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/dir.c1
-rw-r--r--fs/ext4/namei.c12
2 files changed, 11 insertions, 2 deletions
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 80a28b297279..3882fbc5e215 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -185,6 +185,7 @@ static int ext4_readdir(struct file *filp,
185 "at offset %llu", 185 "at offset %llu",
186 (unsigned long long)filp->f_pos); 186 (unsigned long long)filp->f_pos);
187 filp->f_pos += sb->s_blocksize - offset; 187 filp->f_pos += sb->s_blocksize - offset;
188 brelse(bh);
188 continue; 189 continue;
189 } 190 }
190 set_buffer_verified(bh); 191 set_buffer_verified(bh);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index f9ed946a448e..99813db159d9 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -837,6 +837,7 @@ static int ext4_htree_next_block(struct inode *dir, __u32 hash,
837 !ext4_dx_csum_verify(dir, 837 !ext4_dx_csum_verify(dir,
838 (struct ext4_dir_entry *)bh->b_data)) { 838 (struct ext4_dir_entry *)bh->b_data)) {
839 ext4_warning(dir->i_sb, "Node failed checksum"); 839 ext4_warning(dir->i_sb, "Node failed checksum");
840 brelse(bh);
840 return -EIO; 841 return -EIO;
841 } 842 }
842 set_buffer_verified(bh); 843 set_buffer_verified(bh);
@@ -877,8 +878,11 @@ static int htree_dirblock_to_tree(struct file *dir_file,
877 } 878 }
878 879
879 if (!buffer_verified(bh) && 880 if (!buffer_verified(bh) &&
880 !ext4_dirent_csum_verify(dir, (struct ext4_dir_entry *)bh->b_data)) 881 !ext4_dirent_csum_verify(dir,
882 (struct ext4_dir_entry *)bh->b_data)) {
883 brelse(bh);
881 return -EIO; 884 return -EIO;
885 }
882 set_buffer_verified(bh); 886 set_buffer_verified(bh);
883 887
884 de = (struct ext4_dir_entry_2 *) bh->b_data; 888 de = (struct ext4_dir_entry_2 *) bh->b_data;
@@ -1929,8 +1933,10 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
1929 } 1933 }
1930 if (!buffer_verified(bh) && 1934 if (!buffer_verified(bh) &&
1931 !ext4_dirent_csum_verify(dir, 1935 !ext4_dirent_csum_verify(dir,
1932 (struct ext4_dir_entry *)bh->b_data)) 1936 (struct ext4_dir_entry *)bh->b_data)) {
1937 brelse(bh);
1933 return -EIO; 1938 return -EIO;
1939 }
1934 set_buffer_verified(bh); 1940 set_buffer_verified(bh);
1935 retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); 1941 retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh);
1936 if (retval != -ENOSPC) { 1942 if (retval != -ENOSPC) {
@@ -2492,6 +2498,7 @@ static int empty_dir(struct inode *inode)
2492 (struct ext4_dir_entry *)bh->b_data)) { 2498 (struct ext4_dir_entry *)bh->b_data)) {
2493 EXT4_ERROR_INODE(inode, "checksum error reading directory " 2499 EXT4_ERROR_INODE(inode, "checksum error reading directory "
2494 "lblock 0"); 2500 "lblock 0");
2501 brelse(bh);
2495 return -EIO; 2502 return -EIO;
2496 } 2503 }
2497 set_buffer_verified(bh); 2504 set_buffer_verified(bh);
@@ -2536,6 +2543,7 @@ static int empty_dir(struct inode *inode)
2536 (struct ext4_dir_entry *)bh->b_data)) { 2543 (struct ext4_dir_entry *)bh->b_data)) {
2537 EXT4_ERROR_INODE(inode, "checksum error " 2544 EXT4_ERROR_INODE(inode, "checksum error "
2538 "reading directory lblock 0"); 2545 "reading directory lblock 0");
2546 brelse(bh);
2539 return -EIO; 2547 return -EIO;
2540 } 2548 }
2541 set_buffer_verified(bh); 2549 set_buffer_verified(bh);