lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1433096393-9862-11-git-send-email-mateusz.kulikowski@gmail.com>
Date:	Sun, 31 May 2015 20:19:29 +0200
From:	Mateusz Kulikowski <mateusz.kulikowski@...il.com>
To:	gregkh@...uxfoundation.org
Cc:	Mateusz Kulikowski <mateusz.kulikowski@...il.com>,
	dan.carpenter@...cle.com, joe@...ches.com,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCH v5 10/34] staging: rtl8192e: Simplify rtllib_process_probe_response()

- Extract frame_ctl once and use it as variable.
- Drop endian conversion in is_beacon() function
  (used in simplified function only)
- Simplify debug messages
- Invert STYPE checks in debug messages - it is valid
  as only BEACON and PROBE_RESP are allowed

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@...il.com>
---
 drivers/staging/rtl8192e/rtllib_rx.c | 37 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 3dc0583..304404d 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -2457,9 +2457,9 @@ static inline void update_network(struct rtllib_network *dst,
 	dst->BssCcxVerNumber = src->BssCcxVerNumber;
 }
 
-static inline int is_beacon(__le16 fc)
+static inline int is_beacon(u16 fc)
 {
-	return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON);
+	return (WLAN_FC_GET_STYPE(fc) == RTLLIB_STYPE_BEACON);
 }
 
 static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel)
@@ -2500,6 +2500,7 @@ static inline void rtllib_process_probe_response(
 	short renew;
 	struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network),
 						 GFP_ATOMIC);
+	u16 frame_ctl = le16_to_cpu(beacon->header.frame_ctl);
 
 	if (!network)
 		return;
@@ -2528,12 +2529,9 @@ static inline void rtllib_process_probe_response(
 	if (rtllib_network_init(ieee, beacon, network, stats)) {
 		RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n",
 				  escape_essid(info_element->data,
-				  info_element->len),
-				  beacon->header.addr3,
-				  WLAN_FC_GET_STYPE(
-					  le16_to_cpu(beacon->header.frame_ctl)) ==
-				  RTLLIB_STYPE_PROBE_RESP ?
-				  "PROBE RESPONSE" : "BEACON");
+				  info_element->len), beacon->header.addr3,
+				  is_beacon(frame_ctl) ? "BEACON" :
+							 "PROBE RESPONSE");
 		goto free_network;
 	}
 
@@ -2541,8 +2539,7 @@ static inline void rtllib_process_probe_response(
 	if (!rtllib_legal_channel(ieee, network->channel))
 		goto free_network;
 
-	if (WLAN_FC_GET_STYPE(le16_to_cpu(beacon->header.frame_ctl)) ==
-	    RTLLIB_STYPE_PROBE_RESP) {
+	if (WLAN_FC_GET_STYPE(frame_ctl) == RTLLIB_STYPE_PROBE_RESP) {
 		if (IsPassiveChannel(ieee, network->channel)) {
 			netdev_info(ieee->dev,
 				    "GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n",
@@ -2575,7 +2572,7 @@ static inline void rtllib_process_probe_response(
 			else
 				ieee->current_network.buseprotection = false;
 		}
-		if (is_beacon(beacon->header.frame_ctl)) {
+		if (is_beacon(frame_ctl)) {
 			if (ieee->state >= RTLLIB_LINKED)
 				ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
 		}
@@ -2612,22 +2609,18 @@ static inline void rtllib_process_probe_response(
 		RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n",
 				  escape_essid(network->ssid,
 				  network->ssid_len), network->bssid,
-				  WLAN_FC_GET_STYPE(
-					  le16_to_cpu(beacon->header.frame_ctl)) ==
-				  RTLLIB_STYPE_PROBE_RESP ?
-				  "PROBE RESPONSE" : "BEACON");
+				  is_beacon(frame_ctl) ? "BEACON" :
+							 "PROBE RESPONSE");
 		memcpy(target, network, sizeof(*target));
 		list_add_tail(&target->list, &ieee->network_list);
 		if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
 			rtllib_softmac_new_net(ieee, network);
 	} else {
 		RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n",
-				  escape_essid(target->ssid,
-				  target->ssid_len), target->bssid,
-				  WLAN_FC_GET_STYPE(
-					  le16_to_cpu(beacon->header.frame_ctl)) ==
-				  RTLLIB_STYPE_PROBE_RESP ?
-				  "PROBE RESPONSE" : "BEACON");
+				  escape_essid(target->ssid, target->ssid_len),
+				  target->bssid,
+				  is_beacon(frame_ctl) ? "BEACON" :
+							 "PROBE RESPONSE");
 
 		/* we have an entry and we are going to update it. But this
 		 *  entry may be already expired. In this case we do the same
@@ -2648,7 +2641,7 @@ static inline void rtllib_process_probe_response(
 	}
 
 	spin_unlock_irqrestore(&ieee->lock, flags);
-	if (is_beacon(beacon->header.frame_ctl) &&
+	if (is_beacon(frame_ctl) &&
 	    is_same_network(&ieee->current_network, network,
 	    (network->ssid_len ? 1 : 0)) &&
 	    (ieee->state == RTLLIB_LINKED)) {
-- 
1.8.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ