]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mpls: Return early in mpls_label_ok().
authorKuniyuki Iwashima <kuniyu@google.com>
Wed, 29 Oct 2025 17:32:53 +0000 (17:32 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 4 Nov 2025 01:40:44 +0000 (17:40 -0800)
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>
net/mpls/af_mpls.c

index 25c88cba5c48b9082d1c7c2fee7ae332b06f28ee..e3533d85d37254d72bc2b51cc6ea7b64f4898c1b 100644 (file)
@@ -940,24 +940,23 @@ errout:
 static bool mpls_label_ok(struct net *net, unsigned int *index,
                          struct netlink_ext_ack *extack)
 {
-       bool is_ok = true;
-
        /* Reserved labels may not be set */
        if (*index < MPLS_LABEL_FIRST_UNRESERVED) {
                NL_SET_ERR_MSG(extack,
                               "Invalid label - must be MPLS_LABEL_FIRST_UNRESERVED or higher");
-               is_ok = false;
+               return false;
        }
 
        /* The full 20 bit range may not be supported. */
-       if (is_ok && *index >= net->mpls.platform_labels) {
+       if (*index >= net->mpls.platform_labels) {
                NL_SET_ERR_MSG(extack,
                               "Label >= configured maximum in platform_labels");
-               is_ok = false;
+               return false;
        }
 
        *index = array_index_nospec(*index, net->mpls.platform_labels);
-       return is_ok;
+
+       return true;
 }
 
 static int mpls_route_add(struct mpls_route_config *cfg,