1 ext4: call ext4_ext_drop_refs() from ext4_ext_find_extent()
3 In nearly all of the calls to ext4_ext_find_extent() where the caller
4 is trying to recycle the path object, ext4_ext_drop_refs() gets called
5 to release the buffer heads before the path object gets overwritten.
6 To simplify things for the callers, and to avoid the possibility of a
7 memory leak, make ext4_ext_find_extent() responsible for dropping the
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 fs/ext4/extents.c | 11 ++++-------
13 1 file changed, 4 insertions(+), 7 deletions(-)
15 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
16 index f6d8b00..62aa508 100644
17 --- a/fs/ext4/extents.c
18 +++ b/fs/ext4/extents.c
19 @@ -859,8 +859,10 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
20 eh = ext_inode_hdr(inode);
21 depth = ext_depth(inode);
23 - /* account possible depth increase */
26 + ext4_ext_drop_refs(path);
28 + /* account possible depth increase */
29 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2),
32 @@ -1348,7 +1350,6 @@ repeat:
36 - ext4_ext_drop_refs(path);
37 path = ext4_ext_find_extent(inode,
38 (ext4_lblk_t)le32_to_cpu(newext->ee_block),
40 @@ -1361,7 +1362,6 @@ repeat:
44 - ext4_ext_drop_refs(path);
45 path = ext4_ext_find_extent(inode,
46 (ext4_lblk_t)le32_to_cpu(newext->ee_block),
48 @@ -3325,7 +3325,6 @@ static int ext4_split_extent(handle_t *handle,
49 * Update path is required because previous ext4_split_extent_at() may
50 * result in split of original leaf or extent zeroout.
52 - ext4_ext_drop_refs(path);
53 path = ext4_ext_find_extent(inode, map->m_lblk, ppath, 0);
56 @@ -3724,7 +3723,6 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle,
57 EXT4_GET_BLOCKS_CONVERT);
60 - ext4_ext_drop_refs(path);
61 path = ext4_ext_find_extent(inode, map->m_lblk, ppath, 0);
64 @@ -3953,7 +3951,6 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
65 EXT4_GET_BLOCKS_CONVERT_UNWRITTEN);
68 - ext4_ext_drop_refs(path);
69 path = ext4_ext_find_extent(inode, map->m_lblk, ppath, 0);