diff options
author | Chen Gang <gang.chen@asianux.com> | 2013-11-12 18:11:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-12 22:09:33 -0500 |
commit | 3fa582663129330d57d15b97ae534dc1203fc3aa (patch) | |
tree | b648e5937c02b442fba0bd0918e5566b24d8d7f4 /kernel/taskstats.c | |
parent | f02147ef190b3963bb61ec0e140ec47f22889f38 (diff) |
kernel/taskstats.c: add nla_nest_cancel() for failure processing between nla_nest_start() and nla_nest_end()
When failure occurs between nla_nest_start() and nla_nest_end(), we should
call nla_nest_cancel() to clean up related things.
Signed-off-by: Chen Gang <gang.chen@asianux.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/taskstats.c')
-rw-r--r-- | kernel/taskstats.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 145bb4d3bd4d..1db6808c494b 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c | |||
@@ -404,11 +404,15 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid) | |||
404 | if (!na) | 404 | if (!na) |
405 | goto err; | 405 | goto err; |
406 | 406 | ||
407 | if (nla_put(skb, type, sizeof(pid), &pid) < 0) | 407 | if (nla_put(skb, type, sizeof(pid), &pid) < 0) { |
408 | nla_nest_cancel(skb, na); | ||
408 | goto err; | 409 | goto err; |
410 | } | ||
409 | ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); | 411 | ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); |
410 | if (!ret) | 412 | if (!ret) { |
413 | nla_nest_cancel(skb, na); | ||
411 | goto err; | 414 | goto err; |
415 | } | ||
412 | nla_nest_end(skb, na); | 416 | nla_nest_end(skb, na); |
413 | 417 | ||
414 | return nla_data(ret); | 418 | return nla_data(ret); |