diff mbox series

[net-next] tipc: Cleanup tipc_nl_bearer_add() error paths

Message ID 20240213134058.386123-1-syoshida@redhat.com (mailing list archive)
State Accepted
Commit 984328c7657dbf2fea8f67e1171cb93a22d7fc06
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tipc: Cleanup tipc_nl_bearer_add() error paths | 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: 989 this patch: 989
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: 1006 this patch: 1006
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1006 this patch: 1006
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-15--00-00 (tests: 1443)

Commit Message

Shigeru Yoshida Feb. 13, 2024, 1:40 p.m. UTC
Consolidate the error paths of tipc_nl_bearer_add() under the common label
if the function holds rtnl_lock.

Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
---
 net/tipc/bearer.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Comments

Tung Quang Nguyen Feb. 15, 2024, 1:06 a.m. UTC | #1
> net/tipc/bearer.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
>diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 878415c43527..5a526ebafeb4 100644
>--- a/net/tipc/bearer.c
>+++ b/net/tipc/bearer.c
>@@ -1079,30 +1079,27 @@ int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info)
> 	rtnl_lock();
> 	b = tipc_bearer_find(net, name);
> 	if (!b) {
>-		rtnl_unlock();
> 		NL_SET_ERR_MSG(info->extack, "Bearer not found");
>-		return -EINVAL;
>+		err = -EINVAL;
>+		goto out;
> 	}
>
> #ifdef CONFIG_TIPC_MEDIA_UDP
> 	if (attrs[TIPC_NLA_BEARER_UDP_OPTS]) {
> 		if (b->media->type_id != TIPC_MEDIA_TYPE_UDP) {
>-			rtnl_unlock();
> 			NL_SET_ERR_MSG(info->extack, "UDP option is unsupported");
>-			return -EINVAL;
>+			err = -EINVAL;
>+			goto out;
> 		}
>
> 		err = tipc_udp_nl_bearer_add(b,
> 					     attrs[TIPC_NLA_BEARER_UDP_OPTS]);
>-		if (err) {
>-			rtnl_unlock();
>-			return err;
>-		}
> 	}
> #endif
>+out:
> 	rtnl_unlock();
>
>-	return 0;
>+	return err;
> }
>
> int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
>--
>2.43.0
>
Reviewed-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
patchwork-bot+netdevbpf@kernel.org Feb. 15, 2024, 12:30 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 13 Feb 2024 22:40:58 +0900 you wrote:
> Consolidate the error paths of tipc_nl_bearer_add() under the common label
> if the function holds rtnl_lock.
> 
> Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
> ---
>  net/tipc/bearer.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)

Here is the summary with links:
  - [net-next] tipc: Cleanup tipc_nl_bearer_add() error paths
    https://git.kernel.org/netdev/net-next/c/984328c7657d

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 878415c43527..5a526ebafeb4 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -1079,30 +1079,27 @@  int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info)
 	rtnl_lock();
 	b = tipc_bearer_find(net, name);
 	if (!b) {
-		rtnl_unlock();
 		NL_SET_ERR_MSG(info->extack, "Bearer not found");
-		return -EINVAL;
+		err = -EINVAL;
+		goto out;
 	}
 
 #ifdef CONFIG_TIPC_MEDIA_UDP
 	if (attrs[TIPC_NLA_BEARER_UDP_OPTS]) {
 		if (b->media->type_id != TIPC_MEDIA_TYPE_UDP) {
-			rtnl_unlock();
 			NL_SET_ERR_MSG(info->extack, "UDP option is unsupported");
-			return -EINVAL;
+			err = -EINVAL;
+			goto out;
 		}
 
 		err = tipc_udp_nl_bearer_add(b,
 					     attrs[TIPC_NLA_BEARER_UDP_OPTS]);
-		if (err) {
-			rtnl_unlock();
-			return err;
-		}
 	}
 #endif
+out:
 	rtnl_unlock();
 
-	return 0;
+	return err;
 }
 
 int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)