* [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings
@ 2021-08-16 17:30 Aakash Hemadri
2021-08-16 17:30 ` [PATCH 1/2] staging: rtl8732bs: incorrect type in assignment Aakash Hemadri
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Aakash Hemadri @ 2021-08-16 17:30 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Shuah Khan, Bjorn Helgaas, linux-staging, linux-kernel
This patchset fixes the below sparse warnings
rtw_security.c:72:50: warning: incorrect type in assignment (different base types)
rtw_security.c:72:50: expected restricted __le32 [usertype]
rtw_security.c:72:50: got unsigned int
rtw_security.c:80:50: warning: incorrect type in assignment (different base types)
rtw_security.c:80:50: expected restricted __le32 [usertype]
rtw_security.c:80:50: got unsigned int
rtw_security.c:124:33: warning: cast to restricted __le32
rtw_security.c:509:58: warning: incorrect type in assignment (different base types)
rtw_security.c:509:58: expected restricted __le32 [usertype]
rtw_security.c:509:58: got unsigned int
rtw_security.c:517:58: warning: incorrect type in assignment (different base types)
rtw_security.c:517:58: expected restricted __le32 [usertype]
rtw_security.c:517:58: got unsigned int
rtw_security.c:621:41: warning: cast to restricted __le32
This can be applied cleanly on next-20210816, and is compile tested.
Aakash Hemadri (2):
staging: rtl8732bs: incorrect type in assignment
staging: rtl8723bs: cast to restricted __le32
rtw_security.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
--
2.32.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] staging: rtl8732bs: incorrect type in assignment
2021-08-16 17:30 [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Aakash Hemadri
@ 2021-08-16 17:30 ` Aakash Hemadri
2021-08-16 17:30 ` [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32 Aakash Hemadri
2021-08-17 17:54 ` [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Greg Kroah-Hartman
2 siblings, 0 replies; 9+ messages in thread
From: Aakash Hemadri @ 2021-08-16 17:30 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Shuah Khan, Bjorn Helgaas, linux-staging, linux-kernel
Cast u32 to __le32 with __cpu_to_le32 to fix sparse warning:
warning: incorrect type in assignment (different base types)
expected restricted __le32 [usertype]
got unsigned int
Signed-off-by: Aakash Hemadri <aakashhemadri123@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index a99f439328f1..381deeea99d0 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -8,6 +8,7 @@
#include <drv_types.h>
#include <rtw_debug.h>
#include <crypto/aes.h>
+#include <linux/byteorder/little_endian.h>
static const char * const _security_type_str[] = {
"N/A",
@@ -69,7 +70,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
- *((__le32 *)crc) = ~crc32_le(~0, payload, length);
+ *((__le32 *)crc) = __cpu_to_le32(~crc32_le(~0, payload, length));
arc4_setkey(ctx, wepkey, 3 + keylength);
arc4_crypt(ctx, payload, payload, length);
@@ -77,7 +78,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
} else {
length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
- *((__le32 *)crc) = ~crc32_le(~0, payload, length);
+ *((__le32 *)crc) = __cpu_to_le32(~crc32_le(~0, payload, length));
arc4_setkey(ctx, wepkey, 3 + keylength);
arc4_crypt(ctx, payload, payload, length);
arc4_crypt(ctx, payload + length, crc, 4);
@@ -506,7 +507,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */
length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
- *((__le32 *)crc) = ~crc32_le(~0, payload, length);
+ *((__le32 *)crc) =
+ __cpu_to_le32(~crc32_le(~0, payload, length));
arc4_setkey(ctx, rc4key, 16);
arc4_crypt(ctx, payload, payload, length);
@@ -514,7 +516,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
} else {
length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
- *((__le32 *)crc) = ~crc32_le(~0, payload, length);
+ *((__le32 *)crc) =
+ __cpu_to_le32(~crc32_le(~0, payload, length));
arc4_setkey(ctx, rc4key, 16);
arc4_crypt(ctx, payload, payload, length);
--
2.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32
2021-08-16 17:30 [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Aakash Hemadri
2021-08-16 17:30 ` [PATCH 1/2] staging: rtl8732bs: incorrect type in assignment Aakash Hemadri
@ 2021-08-16 17:30 ` Aakash Hemadri
2021-08-17 17:54 ` [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Greg Kroah-Hartman
2 siblings, 0 replies; 9+ messages in thread
From: Aakash Hemadri @ 2021-08-16 17:30 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Shuah Khan, Bjorn Helgaas, linux-staging, linux-kernel
Fix sparse warning:
warning: cast to restricted __le32
Signed-off-by: Aakash Hemadri <aakashhemadri123@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 381deeea99d0..5320b1a46dfb 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -122,7 +122,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) = ~crc32_le(~0, payload, length - 4);
}
}
@@ -621,7 +621,7 @@ 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) = ~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.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings
2021-08-16 17:30 [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Aakash Hemadri
2021-08-16 17:30 ` [PATCH 1/2] staging: rtl8732bs: incorrect type in assignment Aakash Hemadri
2021-08-16 17:30 ` [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32 Aakash Hemadri
@ 2021-08-17 17:54 ` Greg Kroah-Hartman
2021-08-17 19:10 ` Fabio M. De Francesco
2021-08-18 4:40 ` Aakash Hemadri
2 siblings, 2 replies; 9+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-17 17:54 UTC (permalink / raw)
To: Aakash Hemadri; +Cc: Shuah Khan, Bjorn Helgaas, linux-staging, linux-kernel
On Mon, Aug 16, 2021 at 11:00:41PM +0530, Aakash Hemadri wrote:
> This patchset fixes the below sparse warnings
>
> rtw_security.c:72:50: warning: incorrect type in assignment (different base types)
> rtw_security.c:72:50: expected restricted __le32 [usertype]
> rtw_security.c:72:50: got unsigned int
> rtw_security.c:80:50: warning: incorrect type in assignment (different base types)
> rtw_security.c:80:50: expected restricted __le32 [usertype]
> rtw_security.c:80:50: got unsigned int
> rtw_security.c:124:33: warning: cast to restricted __le32
> rtw_security.c:509:58: warning: incorrect type in assignment (different base types)
> rtw_security.c:509:58: expected restricted __le32 [usertype]
> rtw_security.c:509:58: got unsigned int
> rtw_security.c:517:58: warning: incorrect type in assignment (different base types)
> rtw_security.c:517:58: expected restricted __le32 [usertype]
> rtw_security.c:517:58: got unsigned int
> rtw_security.c:621:41: warning: cast to restricted __le32
>
> This can be applied cleanly on next-20210816, and is compile tested.
>
> Aakash Hemadri (2):
> staging: rtl8732bs: incorrect type in assignment
> staging: rtl8723bs: cast to restricted __le32
>
> rtw_security.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
This series does not apply to my tree at all. Please fix up and rebase
and resubmit, after reading the mailing list archives for others that
have attempted do do this type of work in the past for this issue.
It is not a trivial change that is needed...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings
2021-08-17 17:54 ` [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Greg Kroah-Hartman
@ 2021-08-17 19:10 ` Fabio M. De Francesco
2021-08-18 4:42 ` Aakash Hemadri
2021-08-18 4:40 ` Aakash Hemadri
1 sibling, 1 reply; 9+ messages in thread
From: Fabio M. De Francesco @ 2021-08-17 19:10 UTC (permalink / raw)
To: Aakash Hemadri, Greg Kroah-Hartman
Cc: Shuah Khan, Bjorn Helgaas, linux-staging, linux-kernel
On Tuesday, August 17, 2021 7:54:11 PM CEST Greg Kroah-Hartman wrote:
> On Mon, Aug 16, 2021 at 11:00:41PM +0530, Aakash Hemadri wrote:
> > This patchset fixes the below sparse warnings
> >
> > rtw_security.c:72:50: warning: incorrect type in assignment (different base types)
> > rtw_security.c:72:50: expected restricted __le32 [usertype]
> > rtw_security.c:72:50: got unsigned int
> >
> > [...]
>
> This series does not apply to my tree at all. Please fix up and rebase
> and resubmit, after reading the mailing list archives for others that
> have attempted do do this type of work in the past for this issue.
>
> It is not a trivial change that is needed...
Dear Greg,
As I've already pointed out in another message of this thread, your tree has
already these sparse warnings fixed by me with commit aef1c966a364 (that
you applied with a "much nicer!" comment).
So, when Aakash rebases against your current tree, he will not anymore see
those sparse warnings.
Thanks,
Fabio
>
> thanks,
>
> greg k-h
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings
2021-08-17 17:54 ` [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Greg Kroah-Hartman
2021-08-17 19:10 ` Fabio M. De Francesco
@ 2021-08-18 4:40 ` Aakash Hemadri
1 sibling, 0 replies; 9+ messages in thread
From: Aakash Hemadri @ 2021-08-18 4:40 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Shuah Khan, Bjorn Helgaas, linux-staging, linux-kernel
On 21/08/17 07:54PM, Greg Kroah-Hartman wrote:
> This series does not apply to my tree at all. Please fix up and rebase
> and resubmit, after reading the mailing list archives for others that
> have attempted do do this type of work in the past for this issue.
>
> It is not a trivial change that is needed...
Will check what went wrong, and see what I can do.
Thanks,
Aakash Hemadri
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings
2021-08-17 19:10 ` Fabio M. De Francesco
@ 2021-08-18 4:42 ` Aakash Hemadri
0 siblings, 0 replies; 9+ messages in thread
From: Aakash Hemadri @ 2021-08-18 4:42 UTC (permalink / raw)
To: Fabio M. De Francesco
Cc: Greg Kroah-Hartman, Shuah Khan, Bjorn Helgaas, linux-staging,
linux-kernel
On 21/08/17 09:10PM, Fabio M. De Francesco wrote:
> On Tuesday, August 17, 2021 7:54:11 PM CEST Greg Kroah-Hartman wrote:
> > On Mon, Aug 16, 2021 at 11:00:41PM +0530, Aakash Hemadri wrote:
> > > This patchset fixes the below sparse warnings
> > >
> > > rtw_security.c:72:50: warning: incorrect type in assignment (different base types)
> > > rtw_security.c:72:50: expected restricted __le32 [usertype]
> > > rtw_security.c:72:50: got unsigned int
> > >
> > > [...]
> >
> > This series does not apply to my tree at all. Please fix up and rebase
> > and resubmit, after reading the mailing list archives for others that
> > have attempted do do this type of work in the past for this issue.
> >
> > It is not a trivial change that is needed...
>
> Dear Greg,
>
> As I've already pointed out in another message of this thread, your tree has
> already these sparse warnings fixed by me with commit aef1c966a364 (that
> you applied with a "much nicer!" comment).
>
> So, when Aakash rebases against your current tree, he will not anymore see
> those sparse warnings.
Thanks for the patch Fabio! Will rebase and work on something new!
Thanks,
Aakash Hemadri
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32
2021-08-16 17:35 ` [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32 Aakash Hemadri
@ 2021-08-19 9:43 ` David Laight
0 siblings, 0 replies; 9+ messages in thread
From: David Laight @ 2021-08-19 9:43 UTC (permalink / raw)
To: 'Aakash Hemadri', Greg Kroah-Hartman
Cc: Shuah Khan, Bjorn Helgaas, linux-staging, linux-kernel
From: Aakash Hemadri
> Sent: 16 August 2021 18:35
>
> Fix sparse warning:
> warning: cast to restricted __le32
How many different copies of this crappy copy are there?
>
...
> diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c
> b/drivers/staging/rtl8723bs/core/rtw_security.c
> index 381deeea99d0..5320b1a46dfb 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_security.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_security.c
> @@ -122,7 +122,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) = ~crc32_le(~0, payload, length - 4);
You've removed a byteswap which is needed on BE architectures.
> }
> }
> @@ -621,7 +621,7 @@ 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) = ~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])
As above - crc32_le() does a 'little-endian crc' but returns a host-ordered value.
The (horrid) array cast means you need to store a LE value.
There are a dozen better ways to do this - I'm bored of quoting them.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32
2021-08-16 17:35 Aakash Hemadri
@ 2021-08-16 17:35 ` Aakash Hemadri
2021-08-19 9:43 ` David Laight
0 siblings, 1 reply; 9+ messages in thread
From: Aakash Hemadri @ 2021-08-16 17:35 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Shuah Khan, Bjorn Helgaas, linux-staging, linux-kernel
Fix sparse warning:
warning: cast to restricted __le32
Signed-off-by: Aakash Hemadri <aakashhemadri123@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 381deeea99d0..5320b1a46dfb 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -122,7 +122,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) = ~crc32_le(~0, payload, length - 4);
}
}
@@ -621,7 +621,7 @@ 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) = ~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.32.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-08-19 9:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16 17:30 [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Aakash Hemadri
2021-08-16 17:30 ` [PATCH 1/2] staging: rtl8732bs: incorrect type in assignment Aakash Hemadri
2021-08-16 17:30 ` [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32 Aakash Hemadri
2021-08-17 17:54 ` [PATCH 0/2] staging: rtl8732bs: Fix sparse warnings Greg Kroah-Hartman
2021-08-17 19:10 ` Fabio M. De Francesco
2021-08-18 4:42 ` Aakash Hemadri
2021-08-18 4:40 ` Aakash Hemadri
2021-08-16 17:35 Aakash Hemadri
2021-08-16 17:35 ` [PATCH 2/2] staging: rtl8723bs: fix cast to restricted __le32 Aakash Hemadri
2021-08-19 9:43 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).