Jelajahi Sumber

qcacld-3.0: Fix STA_ID usage

In HDD STA_ID is being incorrectly used. This change fixes
following two issues:
1) 0 is treated as invalid STA_ID.
2) In hdd_get_transmit_sta_id function, value of INVALID
STA_ID is used as indication for MC/BC packet. This should
rather be a check against status returned from get_sta_id API.

Change-Id: I1710a73b8698c0fd4c537af35f947293c9ab623d
CRs-Fixed: 2039010
Naveen Rawat 8 tahun lalu
induk
melakukan
ac027cbe3a

+ 6 - 3
core/hdd/src/wlan_hdd_assoc.c

@@ -1692,7 +1692,8 @@ static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
 		pHddCtx->sta_to_adapter[sta_id] = NULL;
 		/* Clear all the peer sta register with TL. */
 		for (i = 0; i < MAX_PEERS; i++) {
-			if (0 == pHddStaCtx->conn_info.staId[i])
+			if (HDD_WLAN_INVALID_STA_ID ==
+				pHddStaCtx->conn_info.staId[i])
 				continue;
 			sta_id = pHddStaCtx->conn_info.staId[i];
 			hdd_debug("Deregister StaID %d", sta_id);
@@ -3317,7 +3318,8 @@ static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
 
 			empty_slots++;
 		} else {
-			if (pHddStaCtx->conn_info.staId[idx] != 0) {
+			if (pHddStaCtx->conn_info.staId[idx] !=
+					HDD_WLAN_INVALID_STA_ID) {
 				valid_idx = idx;
 			} else {
 				/* Found an empty slot */
@@ -3335,7 +3337,8 @@ static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
 	/* Find next active staId, to have a valid sta trigger for TL. */
 	if (fSuccess == true) {
 		if (del_idx == 0) {
-			if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
+			if (pHddStaCtx->conn_info.staId[valid_idx] !=
+					HDD_WLAN_INVALID_STA_ID) {
 				pHddStaCtx->conn_info.staId[0] =
 					pHddStaCtx->conn_info.staId[valid_idx];
 				qdf_copy_macaddr(&pHddStaCtx->conn_info.

+ 1 - 1
core/hdd/src/wlan_hdd_ocb.c

@@ -269,7 +269,7 @@ static int hdd_ocb_register_sta(hdd_adapter_t *adapter)
 		return -EINVAL;
 	}
 
-	if (pHddStaCtx->conn_info.staId[0] != 0 &&
+	if (pHddStaCtx->conn_info.staId[0] != HDD_WLAN_INVALID_STA_ID &&
 	     pHddStaCtx->conn_info.staId[0] != peer_id) {
 		hdd_err("The ID for the OCB station has changed.");
 	}

+ 4 - 3
core/hdd/src/wlan_hdd_tx_rx.c

@@ -395,12 +395,13 @@ static void hdd_get_transmit_sta_id(hdd_adapter_t *adapter,
 			struct sk_buff *skb, uint8_t *station_id)
 {
 	bool mcbc_addr = false;
+	QDF_STATUS status;
 	hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	struct qdf_mac_addr *dst_addr = NULL;
 
 	dst_addr = (struct qdf_mac_addr *)skb->data;
-	hdd_get_peer_sta_id(sta_ctx, dst_addr, station_id);
-	if (*station_id == HDD_WLAN_INVALID_STA_ID) {
+	status = hdd_get_peer_sta_id(sta_ctx, dst_addr, station_id);
+	if (QDF_IS_STATUS_ERROR(status)) {
 		if (QDF_NBUF_CB_GET_IS_BCAST(skb) ||
 				QDF_NBUF_CB_GET_IS_MCAST(skb)) {
 			hdd_info("Received MC/BC packet for transmission");
@@ -987,7 +988,7 @@ int hdd_get_peer_idx(hdd_station_ctx_t *sta_ctx, struct qdf_mac_addr *addr)
 	uint8_t idx;
 
 	for (idx = 0; idx < MAX_PEERS; idx++) {
-		if (sta_ctx->conn_info.staId[idx] == 0)
+		if (sta_ctx->conn_info.staId[idx] == HDD_WLAN_INVALID_STA_ID)
 			continue;
 		if (qdf_mem_cmp(&sta_ctx->conn_info.peerMacAddress[idx],
 				addr, sizeof(struct qdf_mac_addr)))

+ 5 - 3
core/hdd/src/wlan_hdd_wext.c

@@ -3270,8 +3270,9 @@ hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
 	hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
 
 	for (idx = 0; idx < MAX_PEERS; idx++) {
-		if (0 != pHddStaCtx->conn_info.staId[idx] &&
-		    staIdx == pHddStaCtx->conn_info.staId[idx]) {
+		if (HDD_WLAN_INVALID_STA_ID !=
+				pHddStaCtx->conn_info.staId[idx] &&
+				staIdx == pHddStaCtx->conn_info.staId[idx]) {
 			return &pHddStaCtx->conn_info.peerMacAddress[idx];
 		}
 	}
@@ -10130,7 +10131,8 @@ static int __iw_get_char_setnone(struct net_device *dev,
 		int length = 0, buf = 0;
 
 		for (idx = 0; idx < MAX_PEERS; idx++) {
-			if (0 != pHddStaCtx->conn_info.staId[idx]) {
+			if (HDD_WLAN_INVALID_STA_ID !=
+					pHddStaCtx->conn_info.staId[idx]) {
 				buf = snprintf
 					      ((extra + length),
 					      WE_MAX_STR_LEN - length,