lkml.org 
[lkml]   [2021]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] rtw_security: fix cast to restricted __le32
Date
This patch fixes the sparse warning of fix cast to restricted __le32.

Last month, there was a change for replacing private CRC-32 routines with
in-kernel ones.
In that patch, we replaced getcrc32 with crc32_le in calling le32_to_cpu.
le32_to_cpu accepts __le32 type as arg, but crc32_le returns unsigned int.
That how it introduced the sparse warning.

This patch uses __force to fix the warning.

Signed-off-by: Jhih-Ming Huang <fbihjmeric@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index a99f439328f1..2f4da67e31c6 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -121,7 +121,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
arc4_crypt(ctx, payload, payload, length);

/* calculate icv and compare the icv */
- *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
+ *((u32 *)crc) = le32_to_cpu((__force __le32)~crc32_le(~0, payload, length - 4));

}
}
@@ -618,7 +618,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
arc4_setkey(ctx, rc4key, 16);
arc4_crypt(ctx, payload, payload, length);

- *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
+ *((u32 *)crc) = le32_to_cpu((__force __le32)~crc32_le(~0, payload,
+ length - 4));

if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
crc[1] != payload[length - 3] || crc[0] != payload[length - 4])
--
2.25.1
\
 
 \ /
  Last update: 2021-06-13 14:29    [W:0.303 / U:5.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site