[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200115121041.10863-45-Jerome.Pouiller@silabs.com>
Date: Wed, 15 Jan 2020 12:13:07 +0000
From: Jérôme Pouiller <Jerome.Pouiller@...abs.com>
To: "devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
"linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Kalle Valo <kvalo@...eaurora.org>,
"David S . Miller" <davem@...emloft.net>,
Jérôme Pouiller <Jerome.Pouiller@...abs.com>
Subject: [PATCH 44/65] staging: wfx: fix possible overflow on jiffies
comparaison
From: Jérôme Pouiller <jerome.pouiller@...abs.com>
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: Jérôme Pouiller <jerome.pouiller@...abs.com>
---
drivers/staging/wfx/data_tx.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
index 60459299a3a9..704ebfe1cd05 100644
--- a/drivers/staging/wfx/data_tx.c
+++ b/drivers/staging/wfx/data_tx.c
@@ -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)
{
int i, ret = 0;
- unsigned long max_inactivity = 0;
- unsigned long now = jiffies;
+ unsigned long oldest;
spin_lock_bh(&wvif->ps_state_lock);
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)
break;
} else if (wvif->link_id_db[i].status != WFX_LINK_HARD &&
!wvif->wdev->tx_queue_stats.link_map_cache[i + 1]) {
- unsigned long inactivity =
- now - wvif->link_id_db[i].timestamp;
-
- if (inactivity < max_inactivity)
- continue;
- max_inactivity = inactivity;
- ret = i + 1;
+ if (!ret || time_after(oldest, wvif->link_id_db[i].timestamp)) {
+ oldest = wvif->link_id_db[i].timestamp;
+ ret = i + 1;
+ }
}
}
--
2.25.0
Powered by blists - more mailing lists