Skip to content

Commit

Permalink
kernel/taskstats.c: add nla_nest_cancel() for failure processing betw…
Browse files Browse the repository at this point in the history
…een 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>
  • Loading branch information
Chen Gang authored and torvalds committed Nov 13, 2013
1 parent f02147e commit 3fa5826
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel/taskstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,15 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid)
if (!na)
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;
}
ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats));
if (!ret)
if (!ret) {
nla_nest_cancel(skb, na);
goto err;
}
nla_nest_end(skb, na);

return nla_data(ret);
Expand Down

0 comments on commit 3fa5826

Please sign in to comment.