2022-04-14 16:15:22

by Michael Straube

[permalink] [raw]
Subject: [PATCH 1/7] staging: r8188eu: fix struct rt_firmware_hdr

The structure rt_firmware_hdr is wrong, there are two issues.

The first issue is that the size of struct rt_firmware_hdr is 33 bytes
but the header in the firmware file is 32 bytes long.

The hexdump of rtl8188eufw.bin shows that the field Rsvd1 of struct
rt_firmware_hdr should be u8 instead of __le16.

OFFSET rtl8188eufw.bin
-----------------------------------------------------------
0x00000000 E1 88 10 00 0B 00 01 00 01 21 11 27 30 36 00 00
0x00000010 2D 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00000020 02 45 4E 00 00 00 00 00 00 00 00 00 00 00 00 00

0x00000000 E1 88 10 00 0B 00 01 00 01 21 11 27 30 36 00 00
^ ^ ^ ^ ^ ^
Subversion Rsvd1 Month Date Hour Minute

This was figured out by looking at struct rtlwifi_firmware_header in
drivers/net/wireless/rtlwifi/wifi.h and the firmware file that the
rtlwifi/rtl8188ee driver uses.

The second issue is that the u16 and u32 fields sould be __le16 and
__le32.

Change the field Rsvd1 to u8 and the u16, u32 fileds to __le16, __le32.

Both issues had no effect because the header size is actually hardcoded
to 32 where it is used in the code. Also the fields after Subversion
are not used and the bytes of the u16 and u32 fields are all zero.

Fixes: 7884fc0a1473 ("staging: r8188eu: introduce new include dir for RTL8188eu driver")
Signed-off-by: Michael Straube <[email protected]>
---
drivers/staging/r8188eu/core/rtw_fw.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_fw.c b/drivers/staging/r8188eu/core/rtw_fw.c
index 8620f3c92b52..7cd08268f3b9 100644
--- a/drivers/staging/r8188eu/core/rtw_fw.c
+++ b/drivers/staging/r8188eu/core/rtw_fw.c
@@ -29,7 +29,7 @@ struct rt_firmware_hdr {
* FW for different conditions */
__le16 Version; /* FW Version */
u8 Subversion; /* FW Subversion, default 0x00 */
- u16 Rsvd1;
+ u8 Rsvd1;

/* LONG WORD 1 ---- */
u8 Month; /* Release time Month field */
@@ -42,11 +42,11 @@ struct rt_firmware_hdr {

/* LONG WORD 2 ---- */
__le32 SvnIdx; /* The SVN entry index */
- u32 Rsvd3;
+ __le32 Rsvd3;

/* LONG WORD 3 ---- */
- u32 Rsvd4;
- u32 Rsvd5;
+ __le32 Rsvd4;
+ __le32 Rsvd5;
};

static void fw_download_enable(struct adapter *padapter, bool enable)
--
2.35.1


2022-04-16 01:36:37

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 1/7] staging: r8188eu: fix struct rt_firmware_hdr

On 4/14/22 03:38, Michael Straube wrote:
> The second issue is that the u16 and u32 fields sould be __le16 and
> __le32.
>
> Change the field Rsvd1 to u8 and the u16, u32 fileds to __le16, __le32.

There is a typo here.

Note that the various RsvdN fields are just reserving space and will never be
referenced, thus it does not matter if they are u32 or __le32. It is OK to
change them, but it is not wrong to leave them the way they are.

Larry