lost sysctl fix

try_attach() should walk into the matching subdirectory, not the first one...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Tested-by: Valdis.Kletnieks@vt.edu
Tested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Al Viro and committed by
Linus Torvalds
bfbcf034 8be1a6d6

+9 -7
+9 -7
kernel/sysctl.c
··· 1680 1681 core_initcall(sysctl_init); 1682 1683 - static int is_branch_in(struct ctl_table *branch, struct ctl_table *table) 1684 { 1685 struct ctl_table *p; 1686 const char *s = branch->procname; 1687 1688 /* branch should have named subdirectory as its first element */ 1689 if (!s || !branch->child) 1690 - return 0; 1691 1692 /* ... and nothing else */ 1693 if (branch[1].procname || branch[1].ctl_name) 1694 - return 0; 1695 1696 /* table should contain subdirectory with the same name */ 1697 for (p = table; p->procname || p->ctl_name; p++) { 1698 if (!p->child) 1699 continue; 1700 if (p->procname && strcmp(p->procname, s) == 0) 1701 - return 1; 1702 } 1703 - return 0; 1704 } 1705 1706 /* see if attaching q to p would be an improvement */ 1707 static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1708 { 1709 struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1710 int is_better = 0; 1711 int not_in_parent = !p->attached_by; 1712 1713 - while (is_branch_in(by, to)) { 1714 if (by == q->attached_by) 1715 is_better = 1; 1716 if (to == p->attached_by) 1717 not_in_parent = 1; 1718 by = by->child; 1719 - to = to->child; 1720 } 1721 1722 if (is_better && not_in_parent) {
··· 1680 1681 core_initcall(sysctl_init); 1682 1683 + static struct ctl_table *is_branch_in(struct ctl_table *branch, 1684 + struct ctl_table *table) 1685 { 1686 struct ctl_table *p; 1687 const char *s = branch->procname; 1688 1689 /* branch should have named subdirectory as its first element */ 1690 if (!s || !branch->child) 1691 + return NULL; 1692 1693 /* ... and nothing else */ 1694 if (branch[1].procname || branch[1].ctl_name) 1695 + return NULL; 1696 1697 /* table should contain subdirectory with the same name */ 1698 for (p = table; p->procname || p->ctl_name; p++) { 1699 if (!p->child) 1700 continue; 1701 if (p->procname && strcmp(p->procname, s) == 0) 1702 + return p; 1703 } 1704 + return NULL; 1705 } 1706 1707 /* see if attaching q to p would be an improvement */ 1708 static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1709 { 1710 struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1711 + struct ctl_table *next; 1712 int is_better = 0; 1713 int not_in_parent = !p->attached_by; 1714 1715 + while ((next = is_branch_in(by, to)) != NULL) { 1716 if (by == q->attached_by) 1717 is_better = 1; 1718 if (to == p->attached_by) 1719 not_in_parent = 1; 1720 by = by->child; 1721 + to = next->child; 1722 } 1723 1724 if (is_better && not_in_parent) {