Skip to contentSkip to conversation

staging: rtl8192e: Fix alignment of structs and truncated writing

PATCH New Philipp Hortmann 1 participant 3 messages Sep 18, 2023 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: rtl8192e: Fix alignment of structs and truncated writing

Fix alignment of structs and compiler warning truncated writing.

Tested with rtl8192e (WLL6130-D99) in Mode n (12.2 MB/s) Transferred this patch over wlan connection of rtl8192e.

Philipp Hortmann (2):
staging: rtl8192e: Fix alignment of structs in rtllib.h to two
staging: rtl8192e: Fix compiler warning truncated writing of
iwe.u.name

 drivers/staging/rtl8192e/rtllib.h    | 14 +++++++-------
 drivers/staging/rtl8192e/rtllib_wx.c |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.42.0
#1 lore raw

PATCH 1/2 staging: rtl8192e: Fix alignment of structs in rtllib.h to two

Fix alignment of structs to even addresses to support all architectures.

---
 drivers/staging/rtl8192e/rtllib.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8192e/rtllib.h +7 -7
index 5517b9df65be..7d26910a0b16 100644
@@ -642,23 +642,23 @@ struct rtllib_authentication {
 	__le16 status;
 	/*challenge*/
 	struct rtllib_info_element info_element[];
-} __packed;
+} __packed __aligned(2);
 
 struct rtllib_disauth {
 	struct ieee80211_hdr_3addr header;
 	__le16 reason;
-} __packed;
+} __packed __aligned(2);
 
 struct rtllib_disassoc {
 	struct ieee80211_hdr_3addr header;
 	__le16 reason;
-} __packed;
+} __packed __aligned(2);
 
 struct rtllib_probe_request {
 	struct ieee80211_hdr_3addr header;
 	/* SSID, supported rates */
 	struct rtllib_info_element info_element[];
-} __packed;
+} __packed __aligned(2);
 
 struct rtllib_probe_response {
 	struct ieee80211_hdr_3addr header;
@@ -669,7 +669,7 @@ struct rtllib_probe_response {
 	 * CF params, IBSS params, TIM (if beacon), RSN
 	 */
 	struct rtllib_info_element info_element[];
-} __packed;
+} __packed __aligned(2);
 
 /* Alias beacon for probe_response */
 #define rtllib_beacon rtllib_probe_response
@@ -680,7 +680,7 @@ struct rtllib_assoc_request_frame {
 	__le16 listen_interval;
 	/* SSID, supported rates, RSN */
 	struct rtllib_info_element info_element[];
-} __packed;
+} __packed __aligned(2);
 
 struct rtllib_assoc_response_frame {
 	struct ieee80211_hdr_3addr header;
@@ -688,7 +688,7 @@ struct rtllib_assoc_response_frame {
 	__le16 status;
 	__le16 aid;
 	struct rtllib_info_element info_element[]; /* supported rates */
-} __packed;
+} __packed __aligned(2);
 
 struct rtllib_txb {
 	u8 nr_frags;
Signature · 1 line
2.42.0
#2 lore raw

PATCH 2/2 staging: rtl8192e: Fix compiler warning truncated writing of iwe.u.name

In reply to Philipp Hortmann

iwe.u.name and proto_name have both 16 bytes of space. But when writing to iwe.u.name the first 10 bytes are used by the fixed string "IEEE802.11". Evaluating the code shows that only the following strings can occur in proto_name: "N-24G", "g", "b", "bg". Therefore it is sufficient to shorten proto_name to 6 bytes.

---
 drivers/staging/rtl8192e/rtllib_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_wx.c +1 -1
index e9469bfef3dd..a37250de7ba3 100644
@@ -29,7 +29,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
 					   struct iw_request_info *info)
 {
 	char custom[MAX_CUSTOM_LEN];
-	char proto_name[IFNAMSIZ];
+	char proto_name[6];
 	char *pname = proto_name;
 	char *p;
 	struct iw_event iwe;
Signature · 1 line
2.42.0