diff options
Diffstat (limited to 'fs/ext4/xattr.c')
-rw-r--r-- | fs/ext4/xattr.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index f36fc5d5b257..7643d52c776c 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -1031,10 +1031,8 @@ static int ext4_xattr_inode_update_ref(handle_t *handle, struct inode *ea_inode, | |||
1031 | inode_lock(ea_inode); | 1031 | inode_lock(ea_inode); |
1032 | 1032 | ||
1033 | ret = ext4_reserve_inode_write(handle, ea_inode, &iloc); | 1033 | ret = ext4_reserve_inode_write(handle, ea_inode, &iloc); |
1034 | if (ret) { | 1034 | if (ret) |
1035 | iloc.bh = NULL; | ||
1036 | goto out; | 1035 | goto out; |
1037 | } | ||
1038 | 1036 | ||
1039 | ref_count = ext4_xattr_inode_get_ref(ea_inode); | 1037 | ref_count = ext4_xattr_inode_get_ref(ea_inode); |
1040 | ref_count += ref_change; | 1038 | ref_count += ref_change; |
@@ -1080,12 +1078,10 @@ static int ext4_xattr_inode_update_ref(handle_t *handle, struct inode *ea_inode, | |||
1080 | } | 1078 | } |
1081 | 1079 | ||
1082 | ret = ext4_mark_iloc_dirty(handle, ea_inode, &iloc); | 1080 | ret = ext4_mark_iloc_dirty(handle, ea_inode, &iloc); |
1083 | iloc.bh = NULL; | ||
1084 | if (ret) | 1081 | if (ret) |
1085 | ext4_warning_inode(ea_inode, | 1082 | ext4_warning_inode(ea_inode, |
1086 | "ext4_mark_iloc_dirty() failed ret=%d", ret); | 1083 | "ext4_mark_iloc_dirty() failed ret=%d", ret); |
1087 | out: | 1084 | out: |
1088 | brelse(iloc.bh); | ||
1089 | inode_unlock(ea_inode); | 1085 | inode_unlock(ea_inode); |
1090 | return ret; | 1086 | return ret; |
1091 | } | 1087 | } |
@@ -1388,6 +1384,12 @@ retry: | |||
1388 | bh = ext4_getblk(handle, ea_inode, block, 0); | 1384 | bh = ext4_getblk(handle, ea_inode, block, 0); |
1389 | if (IS_ERR(bh)) | 1385 | if (IS_ERR(bh)) |
1390 | return PTR_ERR(bh); | 1386 | return PTR_ERR(bh); |
1387 | if (!bh) { | ||
1388 | WARN_ON_ONCE(1); | ||
1389 | EXT4_ERROR_INODE(ea_inode, | ||
1390 | "ext4_getblk() return bh = NULL"); | ||
1391 | return -EFSCORRUPTED; | ||
1392 | } | ||
1391 | ret = ext4_journal_get_write_access(handle, bh); | 1393 | ret = ext4_journal_get_write_access(handle, bh); |
1392 | if (ret) | 1394 | if (ret) |
1393 | goto out; | 1395 | goto out; |
@@ -2276,8 +2278,10 @@ static struct buffer_head *ext4_xattr_get_block(struct inode *inode) | |||
2276 | if (!bh) | 2278 | if (!bh) |
2277 | return ERR_PTR(-EIO); | 2279 | return ERR_PTR(-EIO); |
2278 | error = ext4_xattr_check_block(inode, bh); | 2280 | error = ext4_xattr_check_block(inode, bh); |
2279 | if (error) | 2281 | if (error) { |
2282 | brelse(bh); | ||
2280 | return ERR_PTR(error); | 2283 | return ERR_PTR(error); |
2284 | } | ||
2281 | return bh; | 2285 | return bh; |
2282 | } | 2286 | } |
2283 | 2287 | ||
@@ -2397,6 +2401,8 @@ retry_inode: | |||
2397 | error = ext4_xattr_block_set(handle, inode, &i, &bs); | 2401 | error = ext4_xattr_block_set(handle, inode, &i, &bs); |
2398 | } else if (error == -ENOSPC) { | 2402 | } else if (error == -ENOSPC) { |
2399 | if (EXT4_I(inode)->i_file_acl && !bs.s.base) { | 2403 | if (EXT4_I(inode)->i_file_acl && !bs.s.base) { |
2404 | brelse(bs.bh); | ||
2405 | bs.bh = NULL; | ||
2400 | error = ext4_xattr_block_find(inode, &i, &bs); | 2406 | error = ext4_xattr_block_find(inode, &i, &bs); |
2401 | if (error) | 2407 | if (error) |
2402 | goto cleanup; | 2408 | goto cleanup; |
@@ -2617,6 +2623,8 @@ out: | |||
2617 | kfree(buffer); | 2623 | kfree(buffer); |
2618 | if (is) | 2624 | if (is) |
2619 | brelse(is->iloc.bh); | 2625 | brelse(is->iloc.bh); |
2626 | if (bs) | ||
2627 | brelse(bs->bh); | ||
2620 | kfree(is); | 2628 | kfree(is); |
2621 | kfree(bs); | 2629 | kfree(bs); |
2622 | 2630 | ||
@@ -2696,7 +2704,6 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, | |||
2696 | struct ext4_inode *raw_inode, handle_t *handle) | 2704 | struct ext4_inode *raw_inode, handle_t *handle) |
2697 | { | 2705 | { |
2698 | struct ext4_xattr_ibody_header *header; | 2706 | struct ext4_xattr_ibody_header *header; |
2699 | struct buffer_head *bh; | ||
2700 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); | 2707 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
2701 | static unsigned int mnt_count; | 2708 | static unsigned int mnt_count; |
2702 | size_t min_offs; | 2709 | size_t min_offs; |
@@ -2737,13 +2744,17 @@ retry: | |||
2737 | * EA block can hold new_extra_isize bytes. | 2744 | * EA block can hold new_extra_isize bytes. |
2738 | */ | 2745 | */ |
2739 | if (EXT4_I(inode)->i_file_acl) { | 2746 | if (EXT4_I(inode)->i_file_acl) { |
2747 | struct buffer_head *bh; | ||
2748 | |||
2740 | bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); | 2749 | bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); |
2741 | error = -EIO; | 2750 | error = -EIO; |
2742 | if (!bh) | 2751 | if (!bh) |
2743 | goto cleanup; | 2752 | goto cleanup; |
2744 | error = ext4_xattr_check_block(inode, bh); | 2753 | error = ext4_xattr_check_block(inode, bh); |
2745 | if (error) | 2754 | if (error) { |
2755 | brelse(bh); | ||
2746 | goto cleanup; | 2756 | goto cleanup; |
2757 | } | ||
2747 | base = BHDR(bh); | 2758 | base = BHDR(bh); |
2748 | end = bh->b_data + bh->b_size; | 2759 | end = bh->b_data + bh->b_size; |
2749 | min_offs = end - base; | 2760 | min_offs = end - base; |