Skip to content

Commit 6bf6104

Browse files
Francesco Ruggeritorvalds
Francesco Ruggeri
authored andcommitted
fs/proc: fix potential unregister_sysctl_table hang
The unregister_sysctl_table() function hangs if all references to its ctl_table_header structure are not dropped. This can happen sometimes because of a leak in proc_sys_lookup(): proc_sys_lookup() gets a reference to the table via lookup_entry(), but it does not release it when a subsequent call to sysctl_follow_link() fails. This patch fixes this leak by making sure the reference is always dropped on return. See also commit 076c3ee ("sysctl: Rewrite proc_sys_lookup introducing find_entry and lookup_entry") which reorganized this code in 3.4. Tested in Linux 3.4.4. Signed-off-by: Francesco Ruggeri <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5698bd7 commit 6bf6104

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/proc/proc_sysctl.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,6 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
462462

463463
err = ERR_PTR(-ENOMEM);
464464
inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
465-
if (h)
466-
sysctl_head_finish(h);
467-
468465
if (!inode)
469466
goto out;
470467

@@ -473,6 +470,8 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
473470
d_add(dentry, inode);
474471

475472
out:
473+
if (h)
474+
sysctl_head_finish(h);
476475
sysctl_head_finish(head);
477476
return err;
478477
}

0 commit comments

Comments
 (0)