Skip to content

Commit

Permalink
genetlink: fix possible memory leak in genl_family_rcv_msg()
Browse files Browse the repository at this point in the history
'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 def3117
(genl: Allow concurrent genl callbacks.)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Wei Yongjun authored and David S. Miller committed Apr 27, 2013
1 parent 78d0b11 commit 50754d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/netlink/genetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -613,14 +613,15 @@ 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);

if (family->post_doit)
family->post_doit(ops, skb, &info);

out:
if (family->parallel_ops)
kfree(attrbuf);

Expand Down

0 comments on commit 50754d2

Please sign in to comment.