summaryrefslogtreecommitdiff
path: root/net/netlink
diff options
context:
space:
mode:
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>2013-04-26 19:34:16 +0400
committerDavid S. Miller <davem@davemloft.net>2013-04-27 07:25:39 +0400
commit50754d2188b04a679a249fb57751542643a436e0 (patch)
treeccffc5647ba1ea8f4d89cabe27a28f3ddfbf77fe /net/netlink
parent78d0b11dcedb21ee432d19eed1a3fa03e8f95353 (diff)
downloadlinux-50754d2188b04a679a249fb57751542643a436e0.tar.xz
genetlink: fix possible memory leak in genl_family_rcv_msg()
'attrbuf' is malloced in genl_family_rcv_msg() when family->maxattr && family->parallel_ops, thus should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Introduced by commit def3117493eafd9dfa1f809d861e0031b2cc8a07 (genl: Allow concurrent genl callbacks.) Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-rw-r--r--net/netlink/genetlink.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 2f72598dd8fe..2fd6dbea327a 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -598,7 +598,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
err = nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr,
ops->policy);
if (err < 0)
- return err;
+ goto out;
}
info.snd_seq = nlh->nlmsg_seq;
@@ -613,7 +613,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
if (family->pre_doit) {
err = family->pre_doit(ops, skb, &info);
if (err)
- return err;
+ goto out;
}
err = ops->doit(skb, &info);
@@ -621,6 +621,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
if (family->post_doit)
family->post_doit(ops, skb, &info);
+out:
if (family->parallel_ops)
kfree(attrbuf);