Skip to content

Commit

Permalink
kernel/taskstats.c: return -ENOMEM when alloc memory fails in add_del…
Browse files Browse the repository at this point in the history
…_listener()

For registering in add_del_listener(), when kmalloc_node() fails, need
return -ENOMEM instead of success code, and cmd_attr_register_cpumask()
wants to know about it.

After modification, give a simple common test "build -> boot up ->
kernel/controllers/cgroup/getdelays by LTP tools".

Signed-off-by: Chen Gang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Chen Gang authored and torvalds committed Nov 13, 2013
1 parent 3fa5826 commit 0d20633
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/taskstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd)
struct listener_list *listeners;
struct listener *s, *tmp, *s2;
unsigned int cpu;
int ret = 0;

if (!cpumask_subset(mask, cpu_possible_mask))
return -EINVAL;
Expand All @@ -304,9 +305,10 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd)
for_each_cpu(cpu, mask) {
s = kmalloc_node(sizeof(struct listener),
GFP_KERNEL, cpu_to_node(cpu));
if (!s)
if (!s) {
ret = -ENOMEM;
goto cleanup;

}
s->pid = pid;
s->valid = 1;

Expand Down Expand Up @@ -339,7 +341,7 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd)
}
up_write(&listeners->sem);
}
return 0;
return ret;
}

static int parse(struct nlattr *na, struct cpumask *mask)
Expand Down

0 comments on commit 0d20633

Please sign in to comment.