]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
taskstats: cgroupstats_user_cmd() may leak on error
authorJesper Juhl <jj@chaosbits.net>
Fri, 5 Oct 2012 00:16:52 +0000 (17:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Oct 2012 18:05:31 +0000 (03:05 +0900)
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>
Signed-off-by: Linus Torvalds <torvalds@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;
        }