sysctl: Correct error return from get_subdir
authorEric W. Biederman <ebiederm@xmission.com>
Tue, 31 Jan 2012 04:37:51 +0000 (20:37 -0800)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 2 Feb 2012 03:20:40 +0000 (19:20 -0800)
When insert_header fails ensure we return the proper error value
from get_subdir.  In practice nothing cares, but there is no
need to be sloppy.

Reported-by: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
fs/proc/proc_sysctl.c

index ebe8b3076db7d8379413ea73a531c78eedb06fdd..722ec116208dcbdfb9e750b83c4bd83cddcf0d90 100644 (file)
@@ -869,6 +869,7 @@ static struct ctl_dir *get_subdir(struct ctl_dir *dir,
 {
        struct ctl_table_set *set = dir->header.set;
        struct ctl_dir *subdir, *new = NULL;
+       int err;
 
        spin_lock(&sysctl_lock);
        subdir = find_subdir(dir, name, namelen);
@@ -890,7 +891,9 @@ static struct ctl_dir *get_subdir(struct ctl_dir *dir,
        if (PTR_ERR(subdir) != -ENOENT)
                goto failed;
 
-       if (insert_header(dir, &new->header))
+       err = insert_header(dir, &new->header);
+       subdir = ERR_PTR(err);
+       if (err)
                goto failed;
        subdir = new;
 found: