Skip to content

Commit 50754d2

Browse files
Wei Yongjundavem330
authored andcommitted
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 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>
1 parent 78d0b11 commit 50754d2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/netlink/genetlink.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
598598
err = nlmsg_parse(nlh, hdrlen, attrbuf, family->maxattr,
599599
ops->policy);
600600
if (err < 0)
601-
return err;
601+
goto out;
602602
}
603603

604604
info.snd_seq = nlh->nlmsg_seq;
@@ -613,14 +613,15 @@ static int genl_family_rcv_msg(struct genl_family *family,
613613
if (family->pre_doit) {
614614
err = family->pre_doit(ops, skb, &info);
615615
if (err)
616-
return err;
616+
goto out;
617617
}
618618

619619
err = ops->doit(skb, &info);
620620

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

624+
out:
624625
if (family->parallel_ops)
625626
kfree(attrbuf);
626627

0 commit comments

Comments
 (0)