[PATCH] taskstats: cgroupstats_user_cmd() may leak on error

From: Jesper Juhl
Date: Tue Aug 07 2012 - 13:59:52 EST


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@xxxxxxxxxxxxx>
---
kernel/taskstats.c | 1 +
1 file changed, 1 insertion(+)

Compile tested only.

diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index d0a3279..37708eb 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -437,6 +437,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;
}
--
1.7.11.4


--
Jesper Juhl <jj@xxxxxxxxxxxxx> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/