diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/taskstats.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index d1db2880d1c..a09a54936f1 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) | |||
291 | if (!cpumask_subset(mask, cpu_possible_mask)) | 291 | if (!cpumask_subset(mask, cpu_possible_mask)) |
292 | return -EINVAL; | 292 | return -EINVAL; |
293 | 293 | ||
294 | s = NULL; | ||
295 | if (isadd == REGISTER) { | 294 | if (isadd == REGISTER) { |
296 | for_each_cpu(cpu, mask) { | 295 | for_each_cpu(cpu, mask) { |
297 | if (!s) | 296 | s = kmalloc_node(sizeof(struct listener), |
298 | s = kmalloc_node(sizeof(struct listener), | 297 | GFP_KERNEL, cpu_to_node(cpu)); |
299 | GFP_KERNEL, cpu_to_node(cpu)); | ||
300 | if (!s) | 298 | if (!s) |
301 | goto cleanup; | 299 | goto cleanup; |
300 | |||
302 | s->pid = pid; | 301 | s->pid = pid; |
303 | INIT_LIST_HEAD(&s->list); | ||
304 | s->valid = 1; | 302 | s->valid = 1; |
305 | 303 | ||
306 | listeners = &per_cpu(listener_array, cpu); | 304 | listeners = &per_cpu(listener_array, cpu); |
307 | down_write(&listeners->sem); | 305 | down_write(&listeners->sem); |
308 | list_for_each_entry_safe(s2, tmp, &listeners->list, list) { | 306 | list_for_each_entry(s2, &listeners->list, list) { |
309 | if (s2->pid == pid) | 307 | if (s2->pid == pid) |
310 | goto next_cpu; | 308 | goto exists; |
311 | } | 309 | } |
312 | list_add(&s->list, &listeners->list); | 310 | list_add(&s->list, &listeners->list); |
313 | s = NULL; | 311 | s = NULL; |
314 | next_cpu: | 312 | exists: |
315 | up_write(&listeners->sem); | 313 | up_write(&listeners->sem); |
314 | kfree(s); /* nop if NULL */ | ||
316 | } | 315 | } |
317 | kfree(s); | ||
318 | return 0; | 316 | return 0; |
319 | } | 317 | } |
320 | 318 | ||