Unionfs: don't dereference null pointers if dir="" was given master_bottom
authorErez Zadok <ezk@cs.sunysb.edu>
Fri, 10 Dec 2010 03:05:51 +0000 (22:05 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 10 Dec 2010 03:05:51 +0000 (22:05 -0500)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/main.c

index 875c56f184031fc69c03c30dad3f44e509b588c2..c48c942fcf8b005ce2af1db1c6c1319ee18a19d0 100644 (file)
@@ -288,7 +288,7 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info
        if (options[0] == '\0') {
                printk(KERN_ERR "unionfs: no branches specified\n");
                err = -EINVAL;
-               goto out;
+               goto out_return;
        }
 
        /*
@@ -304,14 +304,17 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info
                kcalloc(branches, sizeof(struct unionfs_data), GFP_KERNEL);
        if (unlikely(!UNIONFS_SB(sb)->data)) {
                err = -ENOMEM;
-               goto out;
+               goto out_return;
        }
 
        lower_root_info->lower_paths =
                kcalloc(branches, sizeof(struct path), GFP_KERNEL);
        if (unlikely(!lower_root_info->lower_paths)) {
                err = -ENOMEM;
-               goto out;
+               /* free the underlying pointer array */
+               kfree(UNIONFS_SB(sb)->data);
+               UNIONFS_SB(sb)->data = NULL;
+               goto out_return;
        }
 
        /* now parsing a string such as "b1:b2=rw:b3=ro:b4" */
@@ -432,6 +435,7 @@ out:
                lower_root_info->lower_paths = NULL;
                UNIONFS_SB(sb)->data = NULL;
        }
+out_return:
        return err;
 }