ext4: don't dereference null pointer when make_indexed_dir() fails
authorAllison Henderson <achender@linux.vnet.ibm.com>
Sun, 15 May 2011 04:19:41 +0000 (00:19 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 15 May 2011 04:19:41 +0000 (00:19 -0400)
Fix for a null pointer bug found while running punch hole tests

Signed-off-by: Allison Henderson <achender@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/namei.c

index 3c7a06e584693876315dbce91ae5ce444115eee8..b754b7721f51fea4dd943a68e436fe5677f301a0 100644 (file)
@@ -1413,6 +1413,10 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
        frame->at = entries;
        frame->bh = bh;
        bh = bh2;
+
+       ext4_handle_dirty_metadata(handle, dir, frame->bh);
+       ext4_handle_dirty_metadata(handle, dir, bh);
+
        de = do_split(handle,dir, &bh, frame, &hinfo, &retval);
        if (!de) {
                /*
@@ -1421,8 +1425,6 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
                 * with corrupted filesystem.
                 */
                ext4_mark_inode_dirty(handle, dir);
-               ext4_handle_dirty_metadata(handle, dir, frame->bh);
-               ext4_handle_dirty_metadata(handle, dir, bh);
                dx_release(frames);
                return retval;
        }