]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
taskstats: cgroupstats_user_cmd() may leak on error
authorJesper Juhl <jj@chaosbits.net>
Fri, 21 Sep 2012 01:03:35 +0000 (11:03 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 25 Sep 2012 08:46:54 +0000 (18:46 +1000)
If prepare_reply() succeeds we have allocated memory for 'rep_skb'.  If
nla_reserve() then subsequently fails and returns NULL we fail to release
the memory we allocated, thus causing a leak.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Cc: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/taskstats.c

index 610f0838d555393a08de2ac740d31fa05d8bafa9..145bb4d3bd4d9569fb38b33d9afe3496325a6a57 100644 (file)
@@ -445,6 +445,7 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
        na = nla_reserve(rep_skb, CGROUPSTATS_TYPE_CGROUP_STATS,
                                sizeof(struct cgroupstats));
        if (na == NULL) {
+               nlmsg_free(rep_skb);
                rc = -EMSGSIZE;
                goto err;
        }