Browse Source

qcacld-3.0: Prevent hdd_wds_replace_peer_mac modifying mac addr in skb

hdd_wds_replace_peer_mac will modify the input mac addr, the destination
mac addr of skb is modified once we pass skb->data as a pointer to the
hdd_wds_replace_peer_mac.

Use a local variable to get mac addr in skb, then hdd_wds_replace_peer_mac
will not modify mac addr in skb.

Change-Id: Ie0f6f4365b8558a451fa8434832f14aebd56172b
CRs-Fixed: 3196225
Bing Sun 2 years ago
parent
commit
038de6cb99
1 changed files with 26 additions and 28 deletions
  1. 26 28
      core/hdd/src/wlan_hdd_softap_tx_rx.c

+ 26 - 28
core/hdd/src/wlan_hdd_softap_tx_rx.c

@@ -581,44 +581,42 @@ void hdd_softap_get_tx_resource(struct hdd_adapter *adapter,
 static QDF_STATUS hdd_softap_validate_peer_state(struct hdd_adapter *adapter,
 						 struct sk_buff *skb)
 {
-	struct qdf_mac_addr *dest_mac_addr, *mac_addr;
-	static struct qdf_mac_addr bcast_mac_addr = QDF_MAC_ADDR_BCAST_INIT;
+	struct qdf_mac_addr *dest_mac_addr;
+	struct qdf_mac_addr mac_addr;
+	enum ol_txrx_peer_state peer_state;
+	void *soc;
 
 	dest_mac_addr = (struct qdf_mac_addr *)skb->data;
 
-	if (QDF_NBUF_CB_GET_IS_MCAST(skb))
-		mac_addr = &bcast_mac_addr;
-	else
-		mac_addr = dest_mac_addr;
+	if (QDF_NBUF_CB_GET_IS_BCAST(skb) || QDF_NBUF_CB_GET_IS_MCAST(skb))
+		return QDF_STATUS_SUCCESS;
 
-	if (!QDF_NBUF_CB_GET_IS_BCAST(skb) && !QDF_NBUF_CB_GET_IS_MCAST(skb)) {
-		/* for a unicast frame */
-		enum ol_txrx_peer_state peer_state;
-		void *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	/* for a unicast frame */
+	qdf_copy_macaddr(&mac_addr, dest_mac_addr);
+	soc = cds_get_context(QDF_MODULE_ID_SOC);
+	QDF_BUG(soc);
+	hdd_wds_replace_peer_mac(soc, adapter, mac_addr.bytes);
+	peer_state = cdp_peer_state_get(soc, adapter->vdev_id,
+					mac_addr.bytes);
 
-		QDF_BUG(soc);
-		hdd_wds_replace_peer_mac(soc, adapter, mac_addr->bytes);
-		peer_state = cdp_peer_state_get(soc, adapter->vdev_id,
-						mac_addr->bytes);
+	if (peer_state == OL_TXRX_PEER_STATE_INVALID) {
+		hdd_sapd_debug_rl("Failed to find right station");
+		return QDF_STATUS_E_FAILURE;
+	}
 
-		if (peer_state == OL_TXRX_PEER_STATE_INVALID) {
-			hdd_sapd_debug_rl("Failed to find right station");
-			return QDF_STATUS_E_FAILURE;
-		}
+	if (peer_state != OL_TXRX_PEER_STATE_CONN &&
+	    peer_state != OL_TXRX_PEER_STATE_AUTH) {
+		hdd_sapd_debug_rl("Station not connected yet");
+		return QDF_STATUS_E_FAILURE;
+	}
 
-		if (peer_state != OL_TXRX_PEER_STATE_CONN &&
-		    peer_state != OL_TXRX_PEER_STATE_AUTH) {
-			hdd_sapd_debug_rl("Station not connected yet");
+	if (peer_state == OL_TXRX_PEER_STATE_CONN) {
+		if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
+			hdd_sapd_debug_rl("NON-EAPOL packet in non-Authenticated state");
 			return QDF_STATUS_E_FAILURE;
 		}
-
-		if (peer_state == OL_TXRX_PEER_STATE_CONN) {
-			if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
-				hdd_sapd_debug_rl("NON-EAPOL packet in non-Authenticated state");
-				return QDF_STATUS_E_FAILURE;
-			}
-		}
 	}
+
 	return QDF_STATUS_SUCCESS;
 }