Commit def39be0 authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman

staging: wfx: fix possible overflow on jiffies comparaison

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It is recommended to use function time_*() to compare jiffies.
Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200115135338.14374-45-Jerome.Pouiller@silabs.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4e1514c9
...@@ -270,8 +270,7 @@ void wfx_tx_policy_init(struct wfx_vif *wvif) ...@@ -270,8 +270,7 @@ void wfx_tx_policy_init(struct wfx_vif *wvif)
static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac) static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac)
{ {
int i, ret = 0; int i, ret = 0;
unsigned long max_inactivity = 0; unsigned long oldest;
unsigned long now = jiffies;
spin_lock_bh(&wvif->ps_state_lock); spin_lock_bh(&wvif->ps_state_lock);
for (i = 0; i < WFX_MAX_STA_IN_AP_MODE; ++i) { for (i = 0; i < WFX_MAX_STA_IN_AP_MODE; ++i) {
...@@ -280,13 +279,10 @@ static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac) ...@@ -280,13 +279,10 @@ static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac)
break; break;
} else if (wvif->link_id_db[i].status != WFX_LINK_HARD && } else if (wvif->link_id_db[i].status != WFX_LINK_HARD &&
!wvif->wdev->tx_queue_stats.link_map_cache[i + 1]) { !wvif->wdev->tx_queue_stats.link_map_cache[i + 1]) {
unsigned long inactivity = if (!ret || time_after(oldest, wvif->link_id_db[i].timestamp)) {
now - wvif->link_id_db[i].timestamp; oldest = wvif->link_id_db[i].timestamp;
ret = i + 1;
if (inactivity < max_inactivity) }
continue;
max_inactivity = inactivity;
ret = i + 1;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment