Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106351
b: refs/heads/master
c: f7e6ced
h: refs/heads/master
i:
  106349: b1dc252
  106347: 55cfde4
  106343: 0376b5d
  106335: eef3782
v: v3
  • Loading branch information
Al Viro committed Jul 27, 2008
1 parent e2e67e5 commit 8b433d2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 734550921e9b7ab924a43aa3d0bd4239dac4fbf1
refs/heads/master: f7e6ced4061da509f737541ca4dbd44d83a6e82f
6 changes: 6 additions & 0 deletions trunk/include/linux/sysctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,11 @@ extern void setup_sysctl_set(struct ctl_table_set *p,
struct ctl_table_set *parent,
int (*is_seen)(struct ctl_table_set *));

struct ctl_table_header;

extern void sysctl_head_get(struct ctl_table_header *);
extern void sysctl_head_put(struct ctl_table_header *);
extern struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *);
extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
struct ctl_table_header *prev);
Expand Down Expand Up @@ -1073,6 +1078,7 @@ struct ctl_table_header
struct ctl_table *ctl_table;
struct list_head ctl_entry;
int used;
int count;
struct completion *unregistering;
struct ctl_table *ctl_table_arg;
struct ctl_table_root *root;
Expand Down
37 changes: 36 additions & 1 deletion trunk/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,9 @@ static void start_unregistering(struct ctl_table_header *p)
spin_unlock(&sysctl_lock);
wait_for_completion(&wait);
spin_lock(&sysctl_lock);
} else {
/* anything non-NULL; we'll never dereference it */
p->unregistering = ERR_PTR(-EINVAL);
}
/*
* do not remove from the list until nobody holds it; walking the
Expand All @@ -1395,6 +1398,32 @@ static void start_unregistering(struct ctl_table_header *p)
list_del_init(&p->ctl_entry);
}

void sysctl_head_get(struct ctl_table_header *head)
{
spin_lock(&sysctl_lock);
head->count++;
spin_unlock(&sysctl_lock);
}

void sysctl_head_put(struct ctl_table_header *head)
{
spin_lock(&sysctl_lock);
if (!--head->count)
kfree(head);
spin_unlock(&sysctl_lock);
}

struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
{
if (!head)
BUG();
spin_lock(&sysctl_lock);
if (!use_table(head))
head = ERR_PTR(-ENOENT);
spin_unlock(&sysctl_lock);
return head;
}

void sysctl_head_finish(struct ctl_table_header *head)
{
if (!head)
Expand Down Expand Up @@ -1771,6 +1800,7 @@ struct ctl_table_header *__register_sysctl_paths(
header->unregistering = NULL;
header->root = root;
sysctl_set_parent(NULL, header->ctl_table);
header->count = 1;
#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
if (sysctl_check_table(namespaces, header->ctl_table)) {
kfree(header);
Expand Down Expand Up @@ -1834,8 +1864,9 @@ void unregister_sysctl_table(struct ctl_table_header * header)

spin_lock(&sysctl_lock);
start_unregistering(header);
if (!--header->count)
kfree(header);
spin_unlock(&sysctl_lock);
kfree(header);
}

void setup_sysctl_set(struct ctl_table_set *p,
Expand Down Expand Up @@ -1869,6 +1900,10 @@ void setup_sysctl_set(struct ctl_table_set *p,
{
}

void sysctl_head_put(struct ctl_table_header *head)
{
}

#endif /* CONFIG_SYSCTL */

/*
Expand Down

0 comments on commit 8b433d2

Please sign in to comment.