Commit 984328c7 authored by Shigeru Yoshida's avatar Shigeru Yoshida Committed by Paolo Abeni

tipc: Cleanup tipc_nl_bearer_add() error paths

Consolidate the error paths of tipc_nl_bearer_add() under the common label
if the function holds rtnl_lock.
Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
Reviewed-by: default avatarTung Nguyen <tung.q.nguyen@dektech.com.au>
Link: https://lore.kernel.org/r/20240213134058.386123-1-syoshida@redhat.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 038ba1dc
...@@ -1079,30 +1079,27 @@ int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info) ...@@ -1079,30 +1079,27 @@ int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info)
rtnl_lock(); rtnl_lock();
b = tipc_bearer_find(net, name); b = tipc_bearer_find(net, name);
if (!b) { if (!b) {
rtnl_unlock();
NL_SET_ERR_MSG(info->extack, "Bearer not found"); NL_SET_ERR_MSG(info->extack, "Bearer not found");
return -EINVAL; err = -EINVAL;
goto out;
} }
#ifdef CONFIG_TIPC_MEDIA_UDP #ifdef CONFIG_TIPC_MEDIA_UDP
if (attrs[TIPC_NLA_BEARER_UDP_OPTS]) { if (attrs[TIPC_NLA_BEARER_UDP_OPTS]) {
if (b->media->type_id != TIPC_MEDIA_TYPE_UDP) { if (b->media->type_id != TIPC_MEDIA_TYPE_UDP) {
rtnl_unlock();
NL_SET_ERR_MSG(info->extack, "UDP option is unsupported"); NL_SET_ERR_MSG(info->extack, "UDP option is unsupported");
return -EINVAL; err = -EINVAL;
goto out;
} }
err = tipc_udp_nl_bearer_add(b, err = tipc_udp_nl_bearer_add(b,
attrs[TIPC_NLA_BEARER_UDP_OPTS]); attrs[TIPC_NLA_BEARER_UDP_OPTS]);
if (err) {
rtnl_unlock();
return err;
}
} }
#endif #endif
out:
rtnl_unlock(); rtnl_unlock();
return 0; return err;
} }
int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info) int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment