add patch avoid-unneeded-lookup-when-xattr-name-is-invalid
[ext4-patch-queue.git] / fix-error-handling-in-ext4_ext_shift_extents
blob7910587338a4353dc5c8dccbf03cff1e6c645691
1 ext4: fix error handling in ext4_ext_shift_extents
3 From: Dmitry Monakhov <dmonakhov@openvz.org>
5 Fix error handling by adding some.  :-)
7 Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
8 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
9 ---
10  fs/ext4/extents.c |   11 +++++++++--
11  1 files changed, 9 insertions(+), 2 deletions(-)
13 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
14 index 96e0a4b..38be063 100644
15 --- a/fs/ext4/extents.c
16 +++ b/fs/ext4/extents.c
17 @@ -5314,11 +5314,18 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
18          * enough to accomodate the shift.
19          */
20         path = ext4_ext_find_extent(inode, start - 1, NULL, 0);
21 +       if (IS_ERR(path))
22 +               return PTR_ERR(path);
23         depth = path->p_depth;
24         extent =  path[depth].p_ext;
25 -       ex_start = le32_to_cpu(extent->ee_block);
26 -       ex_end = le32_to_cpu(extent->ee_block) +
27 +       if (extent) {
28 +               ex_start = le32_to_cpu(extent->ee_block);
29 +               ex_end = le32_to_cpu(extent->ee_block) +
30                         ext4_ext_get_actual_len(extent);
31 +       } else {
32 +               ex_start = 0;
33 +               ex_end = 0;
34 +       }
35         ext4_ext_drop_refs(path);
36         kfree(path);
38 -- 
39 1.7.1