Skip to content

Commit

Permalink
[NET_SCHED]: cls_flow: fix key mask validity check
Browse files Browse the repository at this point in the history
Since we're using fls(), we need to check whether the value is
non-zero first.

Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kaber authored and davem330 committed Feb 6, 2008
1 parent 0ea9d70 commit 4f25049
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/sched/cls_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4f25049

Please sign in to comment.