summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2024-12-06 15:32:52 +0300
committerJakub Kicinski <kuba@kernel.org>2024-12-07 18:25:09 -0800
commit09310cfd4ea5c3ab2c7a610420205e0a1660bf7e (patch)
tree41fde3ad17dfd5b8d7867505b4bb5b4cfbcce8c8
parentab80e715b70a5d585c922862d70cee58de9cb3cd (diff)
downloadlwn-09310cfd4ea5c3ab2c7a610420205e0a1660bf7e.tar.gz
lwn-09310cfd4ea5c3ab2c7a610420205e0a1660bf7e.zip
rtnetlink: fix error code in rtnl_newlink()
If rtnl_get_peer_net() fails, then propagate the error code. Don't return success. Fixes: 48327566769a ("rtnetlink: fix double call of rtnl_link_get_net_ifla()") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/a2d20cd4-387a-4475-887c-bb7d0e88e25a@stanley.mountain Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--net/core/rtnetlink.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index ab5f201bf0ab..ebcfc2debf1a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3972,8 +3972,10 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
if (ops->peer_type) {
peer_net = rtnl_get_peer_net(ops, data, extack);
- if (IS_ERR(peer_net))
+ if (IS_ERR(peer_net)) {
+ ret = PTR_ERR(peer_net);
goto put_ops;
+ }
if (peer_net)
rtnl_nets_add(&rtnl_nets, peer_net);
}