From c0cb3632f7430d783fd5e40301ffdddbe49f9430 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Sat, 30 Apr 2011 01:30:29 -0400 Subject: [PATCH] Unionfs: don't dereference null pointers if dir="" was given Signed-off-by: Erez Zadok --- fs/unionfs/main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c index 258386e9fd2..9ee58eb4803 100644 --- a/fs/unionfs/main.c +++ b/fs/unionfs/main.c @@ -287,7 +287,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; } /* @@ -303,14 +303,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" */ @@ -427,6 +430,7 @@ out: lower_root_info->lower_paths = NULL; UNIONFS_SB(sb)->data = NULL; } +out_return: return err; } -- 2.34.1