]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/ext4/extents.c
ext4: allow a NULL argument to ext4_ext_drop_refs()
[karo-tx-linux.git] / fs / ext4 / extents.c
index 4f4d5239871292fa26cba479a8f17a08a69a2cd3..538f9a4d96ffbd090c8da30822664042f93c7f81 100644 (file)
@@ -709,9 +709,11 @@ static void ext4_ext_show_move(struct inode *inode, struct ext4_ext_path *path,
 
 void ext4_ext_drop_refs(struct ext4_ext_path *path)
 {
-       int depth = path->p_depth;
-       int i;
+       int depth, i;
 
+       if (!path)
+               return;
+       depth = path->p_depth;
        for (i = 0; i <= depth; i++, path++)
                if (path->p_bh) {
                        brelse(path->p_bh);
@@ -2125,10 +2127,8 @@ merge:
        err = ext4_ext_dirty(handle, inode, path + path->p_depth);
 
 cleanup:
-       if (npath) {
-               ext4_ext_drop_refs(npath);
-               kfree(npath);
-       }
+       ext4_ext_drop_refs(npath);
+       kfree(npath);
        return err;
 }
 
@@ -2283,11 +2283,8 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
                block = es.es_lblk + es.es_len;
        }
 
-       if (path) {
-               ext4_ext_drop_refs(path);
-               kfree(path);
-       }
-
+       ext4_ext_drop_refs(path);
+       kfree(path);
        return err;
 }
 
@@ -3018,11 +3015,9 @@ again:
                }
        }
 out:
-       if (path) {
-               ext4_ext_drop_refs(path);
-               kfree(path);
-               path = NULL;
-       }
+       ext4_ext_drop_refs(path);
+       kfree(path);
+       path = NULL;
        if (err == -EAGAIN)
                goto again;
        ext4_journal_stop(handle);
@@ -4611,10 +4606,8 @@ out:
        map->m_pblk = newblock;
        map->m_len = allocated;
 out2:
-       if (path) {
-               ext4_ext_drop_refs(path);
-               kfree(path);
-       }
+       ext4_ext_drop_refs(path);
+       kfree(path);
 
        trace_ext4_ext_map_blocks_exit(inode, flags, map,
                                       err ? err : allocated);
@@ -5693,16 +5686,11 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
                count -= len;
 
        repeat:
-               if (path1) {
-                       ext4_ext_drop_refs(path1);
-                       kfree(path1);
-                       path1 = NULL;
-               }
-               if (path2) {
-                       ext4_ext_drop_refs(path2);
-                       kfree(path2);
-                       path2 = NULL;
-               }
+               ext4_ext_drop_refs(path1);
+               kfree(path1);
+               ext4_ext_drop_refs(path2);
+               kfree(path2);
+               path1 = path2 = NULL;
        }
        return replaced_count;
 }