diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2017-01-07 20:57:46 +0300 |
---|---|---|
committer | Luca Coelho <luciano.coelho@intel.com> | 2017-02-08 18:54:20 +0300 |
commit | 1aa0ec5cdf60b23dfc152f0e9e205f58b0a546b2 (patch) | |
tree | 800e63cc1524c42c4fb53030afa4774f64451520 /drivers/net/wireless/intel | |
parent | 6eac0e817aee2518a96b5ce9d02b904e0667f370 (diff) | |
download | linux-1aa0ec5cdf60b23dfc152f0e9e205f58b0a546b2.tar.xz |
iwlwifi: dvm: don't call << operator with a negative value
In https://bugzilla.kernel.org/show_bug.cgi?id=177341 Bob
reported a UBSAN WARNING on rs.c.
Undefined behaviour in drivers/net/wireless/intel/iwlwifi/dvm/rs.c:746:18
This because
i = index - 1;
for (mask = (1 << i); i >= 0; i--, mask >>= 1)
is unsafe: i could be negative and hence we can call <<
on a negative value.
This bug doesn't have any real impact since the condition
of the for loop will prevent any usage of mask.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=177341
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel')
-rw-r--r-- | drivers/net/wireless/intel/iwlwifi/dvm/rs.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c index 710dbbefd551..ff44ebc5829d 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c @@ -740,7 +740,10 @@ static u16 rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, /* Find the previous rate that is in the rate mask */ i = index - 1; - for (mask = (1 << i); i >= 0; i--, mask >>= 1) { + if (i >= 0) + mask = BIT(i); + + for (; i >= 0; i--, mask >>= 1) { if (rate_mask & mask) { low = i; break; |