diff options
author | Nogah Frankel <nogahf@mellanox.com> | 2017-12-04 13:31:11 +0200 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-03-03 15:51:45 +0000 |
commit | 94610f7d8508a161105a53f6fb34145af180a667 (patch) | |
tree | adea1333b99e8ceb49ae467c5b16fc50f96a09b9 /include | |
parent | e45719379ab686bc5fb0999469a7a4a718eeb117 (diff) | |
download | linux-stable-94610f7d8508a161105a53f6fb34145af180a667.tar.gz linux-stable-94610f7d8508a161105a53f6fb34145af180a667.tar.bz2 linux-stable-94610f7d8508a161105a53f6fb34145af180a667.zip |
net_sched: red: Avoid illegal values
commit 8afa10cbe281b10371fee5a87ab266e48d71a7f9 upstream.
Check the qmin & qmax values doesn't overflow for the given Wlog value.
Check that qmin <= qmax.
Fixes: a783474591f2 ("[PKT_SCHED]: Generic RED layer")
Signed-off-by: Nogah Frankel <nogahf@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/red.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/net/red.h b/include/net/red.h index ba5039418a93..3618cdfec884 100644 --- a/include/net/red.h +++ b/include/net/red.h @@ -167,6 +167,17 @@ static inline void red_set_vars(struct red_vars *v) v->qcount = -1; } +static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog) +{ + if (fls(qth_min) + Wlog > 32) + return false; + if (fls(qth_max) + Wlog > 32) + return false; + if (qth_max < qth_min) + return false; + return true; +} + static inline void red_set_parms(struct red_parms *p, u32 qth_min, u32 qth_max, u8 Wlog, u8 Plog, u8 Scell_log, u8 *stab, u32 max_P) |