From: Erez Zadok Date: Fri, 10 Dec 2010 03:05:31 +0000 (-0500) Subject: Unionfs: don't dereference null pointers if dir="" was given X-Git-Tag: master_bottom X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=a8b896c6d81bc7b8abf4a75fe4a36138f17d21d5;p=unionfs-2.6.23.y.git Unionfs: don't dereference null pointers if dir="" was given Signed-off-by: Erez Zadok --- diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c index 875c56f1840..c48c942fcf8 100644 --- a/fs/unionfs/main.c +++ b/fs/unionfs/main.c @@ -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; }