Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mpls: Return early in mpls_label_ok().

When mpls_label_ok() returns false, it does not need to update *index.

Let's remove is_ok and return early.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Link: https://patch.msgid.link/20251029173344.2934622-2-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
2214ca1f 209ff7af

+5 -6
+5 -6
net/mpls/af_mpls.c
··· 940 940 static bool mpls_label_ok(struct net *net, unsigned int *index, 941 941 struct netlink_ext_ack *extack) 942 942 { 943 - bool is_ok = true; 944 - 945 943 /* Reserved labels may not be set */ 946 944 if (*index < MPLS_LABEL_FIRST_UNRESERVED) { 947 945 NL_SET_ERR_MSG(extack, 948 946 "Invalid label - must be MPLS_LABEL_FIRST_UNRESERVED or higher"); 949 - is_ok = false; 947 + return false; 950 948 } 951 949 952 950 /* The full 20 bit range may not be supported. */ 953 - if (is_ok && *index >= net->mpls.platform_labels) { 951 + if (*index >= net->mpls.platform_labels) { 954 952 NL_SET_ERR_MSG(extack, 955 953 "Label >= configured maximum in platform_labels"); 956 - is_ok = false; 954 + return false; 957 955 } 958 956 959 957 *index = array_index_nospec(*index, net->mpls.platform_labels); 960 - return is_ok; 958 + 959 + return true; 961 960 } 962 961 963 962 static int mpls_route_add(struct mpls_route_config *cfg,