Commit 50754d21 authored by Wei Yongjun's avatar Wei Yongjun Committed by David S. Miller

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 def31174
(genl: Allow concurrent genl callbacks.)
Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 78d0b11d
...@@ -598,7 +598,7 @@ static int genl_family_rcv_msg(struct genl_family *family, ...@@ -598,7 +598,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
err = nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr, err = nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr,
ops->policy); ops->policy);
if (err < 0) if (err < 0)
return err; goto out;
} }
info.snd_seq = nlh->nlmsg_seq; info.snd_seq = nlh->nlmsg_seq;
...@@ -613,7 +613,7 @@ static int genl_family_rcv_msg(struct genl_family *family, ...@@ -613,7 +613,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
if (family->pre_doit) { if (family->pre_doit) {
err = family->pre_doit(ops, skb, &info); err = family->pre_doit(ops, skb, &info);
if (err) if (err)
return err; goto out;
} }
err = ops->doit(skb, &info); err = ops->doit(skb, &info);
...@@ -621,6 +621,7 @@ static int genl_family_rcv_msg(struct genl_family *family, ...@@ -621,6 +621,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
if (family->post_doit) if (family->post_doit)
family->post_doit(ops, skb, &info); family->post_doit(ops, skb, &info);
out:
if (family->parallel_ops) if (family->parallel_ops)
kfree(attrbuf); kfree(attrbuf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment