net/sched: act_mpls: Fix warning during failed attribute validation
[platform/kernel/linux-rpi.git] / net / sched / act_mpls.c
index e4529b4..db0ef04 100644 (file)
@@ -133,6 +133,11 @@ static int valid_label(const struct nlattr *attr,
 {
        const u32 *label = nla_data(attr);
 
+       if (nla_len(attr) != sizeof(*label)) {
+               NL_SET_ERR_MSG_MOD(extack, "Invalid MPLS label length");
+               return -EINVAL;
+       }
+
        if (*label & ~MPLS_LABEL_MASK || *label == MPLS_LABEL_IMPLNULL) {
                NL_SET_ERR_MSG_MOD(extack, "MPLS label out of range");
                return -EINVAL;
@@ -144,7 +149,8 @@ static int valid_label(const struct nlattr *attr,
 static const struct nla_policy mpls_policy[TCA_MPLS_MAX + 1] = {
        [TCA_MPLS_PARMS]        = NLA_POLICY_EXACT_LEN(sizeof(struct tc_mpls)),
        [TCA_MPLS_PROTO]        = { .type = NLA_U16 },
-       [TCA_MPLS_LABEL]        = NLA_POLICY_VALIDATE_FN(NLA_U32, valid_label),
+       [TCA_MPLS_LABEL]        = NLA_POLICY_VALIDATE_FN(NLA_BINARY,
+                                                        valid_label),
        [TCA_MPLS_TC]           = NLA_POLICY_RANGE(NLA_U8, 0, 7),
        [TCA_MPLS_TTL]          = NLA_POLICY_MIN(NLA_U8, 1),
        [TCA_MPLS_BOS]          = NLA_POLICY_RANGE(NLA_U8, 0, 1),