[PATCH v4 02/35] staging: rtl8192e: Declare ethernet addresses as __aligned(2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add __aligned(2) into ethernet addresses allocated on stack or in non-packed
structures. Use ETH_ALEN as array length in places where it was hardcoded to 6.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@xxxxxxxxx>
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  4 +++-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   |  8 ++++----
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c     |  8 +++++---
 drivers/staging/rtl8192e/rtl819x_Qos.h         |  4 ++--
 drivers/staging/rtl8192e/rtl819x_TS.h          |  2 +-
 drivers/staging/rtl8192e/rtllib.h              | 10 +++++-----
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c   |  3 ++-
 drivers/staging/rtl8192e/rtllib_rx.c           |  6 +++++-
 drivers/staging/rtl8192e/rtllib_softmac.c      | 10 ++++++----
 drivers/staging/rtl8192e/rtllib_tx.c           |  3 ++-
 10 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index aad5cc9..9c6dc82 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -321,7 +321,9 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
 	u8 ICVer8192, ICVer8256;
 	u16 i, usValue, IC_Version;
 	u16 EEPROMId;
-	u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01};
+	static const u8 bMac_Tmp_Addr[ETH_ALEN] __aligned(2) = {
+					0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01
+	};
 
 	RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n");
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 6d60ac4..c25984d 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -2573,8 +2573,9 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 	int ret = -1;
 	struct rtllib_device *ieee = priv->rtllib;
 	u32 key[4];
-	u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-	u8 zero_addr[6] = {0};
+	static const u8 broadcast_addr[ETH_ALEN] __aligned(2) = {
+					0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+	};
 	struct iw_point *p = &wrq->u.data;
 	struct ieee_param *ipw = NULL;
 
@@ -2611,8 +2612,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 				}
 
 				if (ieee->pairwise_key_type) {
-					if (memcmp(ieee->ap_mac_addr, zero_addr,
-					    6) == 0)
+					if (is_zero_ether_addr(ieee->ap_mac_addr))
 						ieee->iw_mode = IW_MODE_ADHOC;
 					memcpy((u8 *)key, ipw->u.crypt.key, 16);
 					EnableHWSecurityConfig8192(dev);
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index 8d6a109..76b8b7c 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -193,7 +193,7 @@ static int r8192_wx_force_mic_error(struct net_device *dev,
 
 #define MAX_ADHOC_PEER_NUM 64
 struct adhoc_peer_entry {
-	unsigned char MacAddr[ETH_ALEN];
+	unsigned char MacAddr[ETH_ALEN] __aligned(2);
 	unsigned char WirelessMode;
 	unsigned char bCurTxBW40MHz;
 };
@@ -987,8 +987,10 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
 
 	ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra);
 	{
-		u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-		u8 zero[6] = {0};
+		static const u8 broadcast_addr[ETH_ALEN] __aligned(2) = {
+					0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+		};
+		static const u8 zero[ETH_ALEN] __aligned(2) = {0};
 		u32 key[4] = {0};
 		struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
 		struct iw_point *encoding = &wrqu->encoding;
diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h
index 55ef7ec..4bdb176 100644
--- a/drivers/staging/rtl8192e/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192e/rtl819x_Qos.h
@@ -255,8 +255,8 @@ union qos_tclas {
 		u8		Priority;
 		u8		ClassifierType;
 		u8		Mask;
-		u8		SrcAddr[6];
-		u8		DstAddr[6];
+		u8		SrcAddr[ETH_ALEN] __aligned(2);
+		u8		DstAddr[ETH_ALEN] __aligned(2);
 		u16		Type;
 	} TYPE0_ETH;
 
diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h
index 8601b1a..28c91fb 100644
--- a/drivers/staging/rtl8192e/rtl819x_TS.h
+++ b/drivers/staging/rtl8192e/rtl819x_TS.h
@@ -35,7 +35,7 @@ struct ts_common_info {
 	struct list_head		List;
 	struct timer_list		SetupTimer;
 	struct timer_list		InactTimer;
-	u8				Addr[6];
+	u8				Addr[ETH_ALEN] __aligned(2);
 	union tspec_body TSpec;
 	union qos_tclas TClass[TCLAS_NUM];
 	u8				TClasProc;
diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index bfec4fd..3674c8b 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -1531,7 +1531,7 @@ struct rtllib_network {
 	u16	CcxRmState[2];
 	bool	bMBssidValid;
 	u8	MBssidMask;
-	u8	MBssid[6];
+	u8	MBssid[ETH_ALEN] __aligned(2);
 	bool	bWithCcxVerNum;
 	u8	BssCcxVerNumber;
 	/* These are network statistics */
@@ -1866,7 +1866,7 @@ struct rt_link_detect {
 
 struct sw_cam_table {
 
-	u8				macaddr[6];
+	u8				macaddr[ETH_ALEN];
 	bool				bused;
 	u8				key_buf[16];
 	u16				key_type;
@@ -1913,7 +1913,7 @@ enum ratr_table_mode_8192s {
 #define	NUM_PMKID_CACHE		16
 struct rt_pmkid_list {
 	u8 bUsed;
-	u8 Bssid[6];
+	u8 Bssid[ETH_ALEN] __aligned(2);
 	u8 PMKID[16];
 	u8 SsidBuf[33];
 	u8 *ssid_octet;
@@ -2083,7 +2083,7 @@ struct rtllib_device {
 	u8 *wpa_ie;
 	size_t wps_ie_len;
 	u8 *wps_ie;
-	u8 ap_mac_addr[6];
+	u8 ap_mac_addr[ETH_ALEN] __aligned(2);
 	u16 pairwise_key_type;
 	u16 group_key_type;
 
@@ -2105,7 +2105,7 @@ struct rtllib_device {
 	u16 rts; /* RTS threshold */
 
 	/* Association info */
-	u8 bssid[ETH_ALEN];
+	u8 bssid[ETH_ALEN] __aligned(2);
 
 	/* This stores infos for the current network.
 	 * Either the network we are associated in INFRASTRUCTURE
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 656b4b3..eda68b9 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -52,7 +52,8 @@ struct rtllib_tkip_data {
 	struct crypto_blkcipher *tx_tfm_arc4;
 	struct crypto_hash *tx_tfm_michael;
 	/* scratch buffers for virt_to_page() (crypto API) */
-	u8 rx_hdr[16], tx_hdr[16];
+	u8 rx_hdr[16] __aligned(2);
+	u8 tx_hdr[16] __aligned(2);
 };
 
 static void *rtllib_tkip_init(int key_idx)
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index bb789cc..e1f4356 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1258,7 +1258,11 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
 	struct rx_ts_record *pTS = NULL;
 	u16 fc, sc, SeqNum = 0;
 	u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0;
-	u8 dst[ETH_ALEN], src[ETH_ALEN], bssid[ETH_ALEN] = {0}, *payload;
+	u8 dst[ETH_ALEN] __aligned(2);
+	u8 src[ETH_ALEN] __aligned(2);
+	u8 bssid[ETH_ALEN] __aligned(2) = {0};
+	u8 *payload;
+
 	size_t hdrlen = 0;
 	bool bToOtherSTA = false;
 	int ret = 0, i = 0;
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index cd758fe..f47b156 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -1932,7 +1932,7 @@ static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb,
 
 void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb)
 {
-	u8 dest[ETH_ALEN];
+	u8 dest[ETH_ALEN] __aligned(2);
 
 	ieee->softmac_stats.rx_probe_rq++;
 	if (probe_rq_parse(ieee, skb, dest) > 0) {
@@ -1944,7 +1944,7 @@ void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb)
 static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee,
 				     struct sk_buff *skb)
 {
-	u8 dest[ETH_ALEN];
+	u8 dest[ETH_ALEN] __aligned(2);
 	int status;
 
 	ieee->softmac_stats.rx_auth_rq++;
@@ -1958,7 +1958,7 @@ static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee,
 				      struct sk_buff *skb)
 {
 
-	u8 dest[ETH_ALEN];
+	u8 dest[ETH_ALEN] __aligned(2);
 
 	ieee->softmac_stats.rx_ass_rq++;
 	if (assoc_rq_parse(skb, dest) != -1)
@@ -2912,7 +2912,9 @@ exit:
 
 struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee)
 {
-	u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+	static const u8 broadcast_addr[] __aligned(2) = {
+					0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+	};
 
 	struct sk_buff *skb;
 	struct rtllib_probe_response *b;
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index 3b15963..56d8c17 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -579,7 +579,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 		.seq_ctl = 0,
 		.qos_ctl = 0
 	};
-	u8 dest[ETH_ALEN], src[ETH_ALEN];
+	u8 dest[ETH_ALEN] __aligned(2);
+	u8 src[ETH_ALEN] __aligned(2);
 	int qos_actived = ieee->current_network.qos_data.active;
 	struct lib80211_crypt_data *crypt = NULL;
 	struct cb_desc *tcb_desc;
-- 
1.8.4.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux