diff mbox series

[net-next] rtnetlink: fix error code in rtnl_newlink()

Message ID a2d20cd4-387a-4475-887c-bb7d0e88e25a@stanley.mountain (mailing list archive)
State Accepted
Commit 09310cfd4ea5c3ab2c7a610420205e0a1660bf7e
Delegated to: Netdev Maintainers
Headers show
Series [net-next] rtnetlink: fix error code in rtnl_newlink() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 5 this patch: 5
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 5 this patch: 5
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-06--18-00 (tests: 764)

Commit Message

Dan Carpenter Dec. 6, 2024, 12:32 p.m. UTC
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>
---
 net/core/rtnetlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Kuniyuki Iwashima Dec. 6, 2024, 11:27 p.m. UTC | #1
> [PATCH net-next] rtnetlink: fix error code in rtnl_newlink()

This should be tagged for net.git.

Otherwise looks good to me.


> 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>

Thanks!

> ---
>  net/core/rtnetlink.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> 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);
>  		}
> -- 
> 2.45.2
Dan Carpenter Dec. 7, 2024, 5:07 p.m. UTC | #2
On Sat, Dec 07, 2024 at 08:27:31AM +0900, Kuniyuki Iwashima wrote:
> > [PATCH net-next] rtnetlink: fix error code in rtnl_newlink()
> 
> This should be tagged for net.git.
> 

Sorry about that.  It was a mistake in my scripting.  I'll fix it.

regards,
dan carpenter
patchwork-bot+netdevbpf@kernel.org Dec. 8, 2024, 2:30 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 6 Dec 2024 15:32:52 +0300 you wrote:
> 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>
> ---
>  net/core/rtnetlink.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Here is the summary with links:
  - [net-next] rtnetlink: fix error code in rtnl_newlink()
    https://git.kernel.org/netdev/net/c/09310cfd4ea5

You are awesome, thank you!
Cong Wang Dec. 10, 2024, 5:58 a.m. UTC | #4
On Fri, Dec 06, 2024 at 03:32:52PM +0300, Dan Carpenter wrote:
> 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>

Oops, how could I miss this even when I mentioned propagation in my commit
message... :-/

Thanks for catching it quickly!
diff mbox series

Patch

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);
 		}