Commit 3fa58266 authored by Chen Gang's avatar Chen Gang Committed by Linus Torvalds

kernel/taskstats.c: add nla_nest_cancel() for failure processing between...

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: default avatarChen Gang <gang.chen@asianux.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f02147ef
...@@ -404,11 +404,15 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid) ...@@ -404,11 +404,15 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid)
if (!na) if (!na)
goto err; goto err;
if (nla_put(skb, type, sizeof(pid), &pid) < 0) if (nla_put(skb, type, sizeof(pid), &pid) < 0) {
nla_nest_cancel(skb, na);
goto err; goto err;
}
ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats));
if (!ret) if (!ret) {
nla_nest_cancel(skb, na);
goto err; goto err;
}
nla_nest_end(skb, na); nla_nest_end(skb, na);
return nla_data(ret); return nla_data(ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment