Skip to content

Commit bd03e76

Browse files
tititiou36kuba-moo
authored andcommitted
rtnetlink: Fix an error handling path in rtnl_newlink()
When some code has been moved in the commit in Fixes, some "return err;" have correctly been changed in goto <some_where_in_the_error_handling_path> but this one was missed. Should "ops->maxtype > RTNL_MAX_TYPE" happen, then some resources would leak. Go through the error handling path to fix these leaks. Fixes: 0d3008d ("rtnetlink: Move ops->validate to rtnl_newlink().") Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/eca90eeb4d9e9a0545772b68aeaab883d9fe2279.1729952228.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1aea2c4 commit bd03e76

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/core/rtnetlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,8 +3840,10 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
38403840
}
38413841

38423842
if (ops) {
3843-
if (ops->maxtype > RTNL_MAX_TYPE)
3844-
return -EINVAL;
3843+
if (ops->maxtype > RTNL_MAX_TYPE) {
3844+
ret = -EINVAL;
3845+
goto put_ops;
3846+
}
38453847

38463848
if (ops->maxtype && linkinfo[IFLA_INFO_DATA]) {
38473849
ret = nla_parse_nested_deprecated(tbs->attr, ops->maxtype,

0 commit comments

Comments
 (0)