[PATCH 4/6] staging: ks7010: use le16_to_cpu for arithmetic

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

 



Code performs arithmetic using a little endian type mixed with
non-endian types. This won't work on big endian architectures.

Wrap little endian type in call to le16_to_cpu before doing arithmetic.

Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
---
 drivers/staging/ks7010/ks_hostif.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index d70472e..8dfe508 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1944,6 +1944,7 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 	struct wpa_suite_t wpa_suite;
 	struct rsn_mode_t rsn_mode;
 	__le32 val;
+	u16 size;
 
 	memset(&wpa_suite, 0, sizeof(wpa_suite));
 
@@ -1992,11 +1993,10 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 				       CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
 			break;
 		}
-
+		size = sizeof(wpa_suite.size) + CIPHER_ID_LEN * le16_to_cpu(wpa_suite.size);
 		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER,
-				       sizeof(wpa_suite.size) +
-				       CIPHER_ID_LEN * wpa_suite.size,
-				       MIB_VALUE_TYPE_OSTRING, &wpa_suite);
+				       size, MIB_VALUE_TYPE_OSTRING,
+				       &wpa_suite);
 		break;
 	case SME_RSN_MCAST_REQUEST:
 		switch (priv->wpa.group_suite) {
@@ -2085,9 +2085,8 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
 			break;
 		}
 
-		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE,
-				       sizeof(wpa_suite.size) +
-				       KEY_MGMT_ID_LEN * wpa_suite.size,
+		size = 	sizeof(wpa_suite.size) + KEY_MGMT_ID_LEN * le16_to_cpu(wpa_suite.size);
+		hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE, size,
 				       MIB_VALUE_TYPE_OSTRING, &wpa_suite);
 		break;
 	case SME_RSN_ENABLED_REQUEST:
-- 
2.7.4

_______________________________________________
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