]> err.no Git - linux-2.6/commitdiff
[NET_SCHED]: cls_flow: fix key mask validity check
authorPatrick McHardy <kaber@trash.net>
Wed, 6 Feb 2008 00:19:59 +0000 (16:19 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Feb 2008 00:19:59 +0000 (16:19 -0800)
Since we're using fls(), we need to check whether the value is
non-zero first.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_flow.c

index 8d7698621f0a0245deca1f17709ee9377d5dcdd6..eeb223cf14cff34af922822ee7f6f31e98b4b048 100644 (file)
@@ -402,12 +402,13 @@ static int flow_change(struct tcf_proto *tp, unsigned long base,
 
        if (tb[TCA_FLOW_KEYS]) {
                keymask = nla_get_u32(tb[TCA_FLOW_KEYS]);
-               if (fls(keymask) - 1 > FLOW_KEY_MAX)
-                       return -EOPNOTSUPP;
 
                nkeys = hweight32(keymask);
                if (nkeys == 0)
                        return -EINVAL;
+
+               if (fls(keymask) - 1 > FLOW_KEY_MAX)
+                       return -EOPNOTSUPP;
        }
 
        err = tcf_exts_validate(tp, tb, tca[TCA_RATE], &e, &flow_ext_map);