Skip to content

Commit

Permalink
ext4: fix smatch warning in move_extent.c's mext_replace_branches()
Browse files Browse the repository at this point in the history
Commit 2147b1a resulted in a new smatch warning:

> fs/ext4/move_extent.c:693 mext_replace_branches()
> 	 warn: variable dereferenced before check 'dext' (see line 683)

Fix this by adding a check to make sure dext is non-NULL before we
derefrence it.

Signed-off-by: Akria Fujita <[email protected]>
[ modified by tytso to make sure an ext4_error is called ]
Signed-off-by: "Theodore Ts'o" <[email protected]>
  • Loading branch information
Akria Fujita authored and tytso committed Feb 2, 2013
1 parent 524c19e commit 87e6987
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/ext4/move_extent.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode,

depth = ext_depth(donor_inode);
dext = donor_path[depth].p_ext;
if (unlikely(!dext))
goto missing_donor_extent;
tmp_dext = *dext;

*err = mext_calc_swap_extents(&tmp_dext, &tmp_oext, orig_off,
Expand All @@ -691,7 +693,8 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode,
/* Loop for the donor extents */
while (1) {
/* The extent for donor must be found. */
if (!dext) {
if (unlikely(!dext)) {
missing_donor_extent:
EXT4_ERROR_INODE(donor_inode,
"The extent for donor must be found");
*err = -EIO;
Expand Down

0 comments on commit 87e6987

Please sign in to comment.