From 9d8d909ff1ec3be3cc431d4ad00b02f64ef14f0c Mon Sep 17 00:00:00 2001 From: Manikanta Pubbisetty Date: Thu, 17 Aug 2023 18:04:39 +0530 Subject: [PATCH] qcacmn: Fix truncation issues due to typecast in QDF time APIs Currently there is an issue wrt truncation in the __qdf_system_time_after() & __qdf_system_time_after_eq() QDF APIs where the input system ticks (jiffies) which are of type unsigned long are getting truncated due to typecast to long before comparison. Due to this typecasting, there is likelihood of a wrong comparison resulting in wrong actions being taken in the caller. Typecast the result of the comparison instead to fix this problem. Change-Id: I4741d9606d9e3462b8dd4736e5612f4a3008000b CRs-Fixed: 3591262 --- qdf/linux/src/i_qdf_time.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qdf/linux/src/i_qdf_time.h b/qdf/linux/src/i_qdf_time.h index 17d25f9ac2..9c9e2329ae 100644 --- a/qdf/linux/src/i_qdf_time.h +++ b/qdf/linux/src/i_qdf_time.h @@ -280,11 +280,11 @@ static inline void __qdf_mdelay(uint32_t msecs) * @b: Time stamp value b * * Return: - * true if a < b else false + * true if a > b else false */ static inline bool __qdf_system_time_after(__qdf_time_t a, __qdf_time_t b) { - return (long)(b) - (long)(a) < 0; + return (long)((b) - (a)) < 0; } /** @@ -311,7 +311,7 @@ static inline bool __qdf_system_time_before(__qdf_time_t a, __qdf_time_t b) */ static inline bool __qdf_system_time_after_eq(__qdf_time_t a, __qdf_time_t b) { - return (long)(a) - (long)(b) >= 0; + return (long)((a) - (b)) >= 0; } /**