소스 검색

qcacld-3.0: rearrange to avoid use-after-free of the skb

The skb buffer is freed after the ealier sanity and then pass along
to connectivity stats tracking. Rearragne the stats tracking into the
scope of the skb sanity to assure the skb poitner is valid before
accessing it and set to NULL after free to make sure it is cleared.

Change-Id: I08106bced48fa8f23955fd261c679a5362ddd7a6
CRs-fixed: 2232362
Ryan Hsu 7 년 전
부모
커밋
da74332d4b
1개의 변경된 파일5개의 추가작업 그리고 5개의 파일을 삭제
  1. 5 5
      core/hdd/src/wlan_hdd_tx_rx.c

+ 5 - 5
core/hdd/src/wlan_hdd_tx_rx.c

@@ -1091,10 +1091,15 @@ drop_pkt_and_release_skb:
 drop_pkt:
 
 	if (skb) {
+		/* track connectivity stats */
+		if (adapter->pkt_type_bitmap)
+			hdd_tx_rx_collect_connectivity_stats_info(skb, adapter,
+						PKT_TYPE_TX_DROPPED, &pkt_type);
 		qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID,
 				      QDF_DP_TRACE_DROP_PACKET_RECORD, 0,
 				      QDF_TX);
 		kfree_skb(skb);
+		skb = NULL;
 	}
 
 drop_pkt_accounting:
@@ -1107,11 +1112,6 @@ drop_pkt_accounting:
 			"%s : ARP packet dropped", __func__);
 	}
 
-	/* track connectivity stats */
-	if (adapter->pkt_type_bitmap)
-		hdd_tx_rx_collect_connectivity_stats_info(skb, adapter,
-						PKT_TYPE_TX_DROPPED, &pkt_type);
-
 	return NETDEV_TX_OK;
 }