mac80211: sanity check CW_min/CW_max towards driver
authorJohannes Berg <johannes.berg@intel.com>
Wed, 8 Oct 2014 12:37:47 +0000 (14:37 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 22 Oct 2014 08:42:09 +0000 (10:42 +0200)
There's no reason to ever set invalid CW_min/CW_max to the
drivers, we should catch it in higher layers. However, the
consequences of setting it wrong can be quite severe, so
double-check at a low level and error out for invalid data.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/driver-ops.h

index 1bbb0790264ffba09c3322f03700f52e17c014ec..3df28e0fa045e23c56196acc0ad1badee811c863 100644 (file)
@@ -631,6 +631,12 @@ static inline int drv_conf_tx(struct ieee80211_local *local,
        if (!check_sdata_in_driver(sdata))
                return -EIO;
 
+       if (WARN_ONCE(params->cw_min == 0 ||
+                     params->cw_min > params->cw_max,
+                     "%s: invalid CW_min/CW_max: %d/%d\n",
+                     sdata->name, params->cw_min, params->cw_max))
+               return -EINVAL;
+
        trace_drv_conf_tx(local, sdata, ac, params);
        if (local->ops->conf_tx)
                ret = local->ops->conf_tx(&local->hw, &sdata->vif,