diff options
author | Paul Mundt <lethal@linux-sh.org> | 2011-08-08 13:45:28 +0900 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2011-08-08 13:45:28 +0900 |
commit | 77c7ee51a062bb595c501ec098125a68999c20c3 (patch) | |
tree | c5060ca5786ef353e005dae04b61d2c49967284d /kernel/taskstats.c | |
parent | 1ba762209491e2496e58baffa3fd65d661f54404 (diff) | |
parent | 322a8b034003c0d46d39af85bf24fee27b902f48 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into sh-latest
Conflicts:
drivers/tty/serial/sh-sci.c
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'kernel/taskstats.c')
-rw-r--r-- | kernel/taskstats.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index d1db2880d1c..e19ce1454ee 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -291,30 +291,28 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd) if (!cpumask_subset(mask, cpu_possible_mask)) return -EINVAL; - s = NULL; if (isadd == REGISTER) { for_each_cpu(cpu, mask) { - if (!s) - s = kmalloc_node(sizeof(struct listener), - GFP_KERNEL, cpu_to_node(cpu)); + s = kmalloc_node(sizeof(struct listener), + GFP_KERNEL, cpu_to_node(cpu)); if (!s) goto cleanup; + s->pid = pid; - INIT_LIST_HEAD(&s->list); s->valid = 1; listeners = &per_cpu(listener_array, cpu); down_write(&listeners->sem); - list_for_each_entry_safe(s2, tmp, &listeners->list, list) { - if (s2->pid == pid) - goto next_cpu; + list_for_each_entry(s2, &listeners->list, list) { + if (s2->pid == pid && s2->valid) + goto exists; } list_add(&s->list, &listeners->list); s = NULL; -next_cpu: +exists: up_write(&listeners->sem); + kfree(s); /* nop if NULL */ } - kfree(s); return 0; } |