Skip to contentSkip to conversation

mwifiex: add missing endian conversions

PATCH In review Tobias Waldekranz 3 participants 5 messages Aug 26, 2013 – Aug 27, 2013 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mwifiex: add missing endian conversions

Fixes multiple locations where a little endian host is assumed during ser/des of messages sent to/received from the chip.

---
 drivers/net/wireless/mwifiex/11n_aggr.c    | 2 +-
 drivers/net/wireless/mwifiex/main.h        | 2 +-
 drivers/net/wireless/mwifiex/sdio.c        | 6 +++---
 drivers/net/wireless/mwifiex/sta_cmdresp.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/mwifiex/11n_aggr.c +1 -1
index a78e065..b53c73c 100644
@@ -69,7 +69,7 @@ mwifiex_11n_form_amsdu_pkt(struct sk_buff *skb_aggr,
 	memcpy(&tx_header->eth803_hdr, skb_src->data, dt_offset);
 
 	/* Copy SNAP header */
-	snap.snap_type = *(u16 *) ((u8 *)skb_src->data + dt_offset);
+	snap.snap_type = le16_to_cpu(*(__le16 *) ((u8 *)skb_src->data + dt_offset));
 	dt_offset += sizeof(u16);
 
 	memcpy(&tx_header->rfc1042_hdr, &snap, sizeof(struct rfc_1042_hdr));
drivers/net/wireless/mwifiex/main.h +1 -1
index 4ef67fc..7797512 100644
@@ -1014,7 +1014,7 @@ mwifiex_netdev_get_priv(struct net_device *dev)
  */
 static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
 {
-	return (*(u32 *)skb->data == PKT_TYPE_MGMT);
+	return (le32_to_cpu(*(__le32 *)skb->data) == PKT_TYPE_MGMT);
 }
 
 int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
drivers/net/wireless/mwifiex/sdio.c +3 -3
index 139c958..27fdbe2 100644
@@ -963,7 +963,7 @@ static int mwifiex_decode_rx_packet(struct mwifiex_adapter *adapter,
 
 	case MWIFIEX_TYPE_EVENT:
 		dev_dbg(adapter->dev, "info: --- Rx: Event ---\n");
-		adapter->event_cause = *(u32 *) skb->data;
+		adapter->event_cause = le32_to_cpu(*(__le32 *) skb->data);
 
 		if ((skb->len > 0) && (skb->len  < MAX_EVENT_SIZE))
 			memcpy(adapter->event_body,
@@ -1088,8 +1088,8 @@ static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter,
 		for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) {
 
 			/* get curr PKT len & type */
-			pkt_len = *(u16 *) &curr_ptr[0];
-			pkt_type = *(u16 *) &curr_ptr[2];
+			pkt_len = le16_to_cpu(*(__le16 *) &curr_ptr[0]);
+			pkt_type = le16_to_cpu(*(__le16 *) &curr_ptr[2]);
 
 			/* copy pkt to deaggr buf */
 			skb_deaggr = card->mpa_rx.skb_arr[pind];
drivers/net/wireless/mwifiex/sta_cmdresp.c +1 -1
index 9f990e1..f12468a8 100644
@@ -280,7 +280,7 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
 
 	tlv_buf = ((u8 *)rate_cfg) +
 			sizeof(struct host_cmd_ds_tx_rate_cfg);
-	tlv_buf_len = *(u16 *) (tlv_buf + sizeof(u16));
+	tlv_buf_len = le16_to_cpu(*(__le16 *) (tlv_buf + sizeof(u16)));
 
 	while (tlv_buf && tlv_buf_len > 0) {
 		tlv = (*tlv_buf);
Signature · 1 line
1.8.3
#1 lore raw

Hi Tobias,

Quoted 2 lines

Fixes multiple locations where a little endian host is assumed during ser/des of messages sent to/received from the chip.

Thanks for your patch.
It doesn't apply to wireless or wireless-next trees.

Which git tree are you using?

Quoted 14 lines
---
 drivers/net/wireless/mwifiex/11n_aggr.c    | 2 +-
 drivers/net/wireless/mwifiex/main.h        | 2 +-
 drivers/net/wireless/mwifiex/sdio.c        | 6 +++---
 drivers/net/wireless/mwifiex/sta_cmdresp.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/mwifiex/11n_aggr.c +0 -0
index a78e065..b53c73c 100644

drivers/net/wireless/mwifiex/11n_aggr.c mwifiex_11n_form_amsdu_pkt(struct sk_buff *skb_aggr, · line 72

Quoted 5 lines
drivers/net/wireless/mwifiex/11n_aggr.c +1 -1
@@ -69,7 +69,7 @@ mwifiex_11n_form_amsdu_pkt(struct sk_buff *skb_aggr,
 	memcpy(&tx_header->eth803_hdr, skb_src->data, dt_offset);
 
 	/* Copy SNAP header */
-	snap.snap_type = *(u16 *) ((u8 *)skb_src->data + dt_offset);
+	snap.snap_type = le16_to_cpu(*(__le16 *) ((u8 *)skb_src->data + dt_offset));

This line exceeds 80 characters. Please break it to two lines.

Thanks,
Bing

#2 lore raw

Hi Tobias,

Quoted 4 lines

Thanks for your patch.
It doesn't apply to wireless or wireless-next trees.

Which git tree are you using?

Never mind. John has merged the patch already.

Regards,
Bing

#3 lore raw
Quoted 11 lines · Bing Zhao

Hi Tobias,

Quoted 4 lines

Thanks for your patch.
It doesn't apply to wireless or wireless-next trees.

Which git tree are you using?

Never mind. John has merged the patch already.

Regards,
Bing

Ok, thanks for picking up the slack :)

It was based on linux-stable/linux-3.10.y, I will base any subsequent patches on wireless-next.

Thanks
- wkz

#4 lore raw
In reply to Bing Zhao
Quoted 9 lines · Bing Zhao

Hi Tobias,

Quoted 2 lines

Fixes multiple locations where a little endian host is assumed during ser/des of messages sent to/received from the chip.

Thanks for your patch.
It doesn't apply to wireless or wireless-next trees.

Which git tree are you using?

I got it to apply with a little trying.

Quoted 16 lines
Quoted 16 lines
---
 drivers/net/wireless/mwifiex/11n_aggr.c    | 2 +-
 drivers/net/wireless/mwifiex/main.h        | 2 +-
 drivers/net/wireless/mwifiex/sdio.c        | 6 +++---
 drivers/net/wireless/mwifiex/sta_cmdresp.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/mwifiex/11n_aggr.c +0 -0
index a78e065..b53c73c 100644
@@ -69,7 +69,7 @@ mwifiex_11n_form_amsdu_pkt(struct sk_buff *skb_aggr,
 	memcpy(&tx_header->eth803_hdr, skb_src->data, dt_offset);
 
Quoted 5 lines

drivers/net/wireless/mwifiex/11n_aggr.c mwifiex_11n_form_amsdu_pkt(struct sk_buff *skb_aggr, · line 72

Quoted 3 lines
drivers/net/wireless/mwifiex/11n_aggr.c +1 -1
 	/* Copy SNAP header */
-	snap.snap_type = *(u16 *) ((u8 *)skb_src->data + dt_offset);
+	snap.snap_type = le16_to_cpu(*(__le16 *) ((u8 *)skb_src->data + dt_offset));

This line exceeds 80 characters. Please break it to two lines.

Please submit a new patch to fix this.

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.