qcacmn: Use correct skb headroom size to update radiotap header

Size of rx_pkt_hdr tlv structure is used to check if there is enough
space in the SKB to add radiotap header.
The issue is seen due to a single SKB can hold the multiple TLVs and
the next subsequent SKB has the data. In this case, there is no headroom
available in the second SKB. Therefore crash seen while adding the
radiotap header in the second SKB.

To fix this issue, check if the SKB has enough headroom space. If not,
drop the frame.

Change-Id: Icd11f946c0aee974dde2ef21f59cfe3d8b87fa5d
CRs-Fixed: 2480719
diff --git a/dp/inc/cdp_txrx_stats_struct.h b/dp/inc/cdp_txrx_stats_struct.h
index 7f72301..aebaad0 100644
--- a/dp/inc/cdp_txrx_stats_struct.h
+++ b/dp/inc/cdp_txrx_stats_struct.h
@@ -1198,6 +1198,7 @@
  * @mesh_filter: Mesh Filtered packets
  * @mon_rx_drop: packets dropped on monitor vap
  * @wifi_parse: rxdma errors due to wifi parse error
+ * @mon_radiotap_update_err: not enough space to update radiotap
  * @pkts: total packets replenished
  * @rxdma_err: rxdma errors for replenished
  * @nbuf_alloc_fail: nbuf alloc failed
@@ -1227,8 +1228,10 @@
 		uint32_t msdu_not_done;
 		uint32_t mec;
 		uint32_t mesh_filter;
-		uint32_t mon_rx_drop;
 		uint32_t wifi_parse;
+		/* Monitor mode related */
+		uint32_t mon_rx_drop;
+		uint32_t mon_radiotap_update_err;
 	} dropped;
 
 	struct {
diff --git a/dp/wifi3.0/dp_rx_mon_dest.c b/dp/wifi3.0/dp_rx_mon_dest.c
index 832b4f6..2cb22f9 100644
--- a/dp/wifi3.0/dp_rx_mon_dest.c
+++ b/dp/wifi3.0/dp_rx_mon_dest.c
@@ -963,8 +963,13 @@
 		if (pdev->ppdu_info.rx_status.chan_num == 0)
 			pdev->ppdu_info.rx_status.chan_num = pdev->mon_chan_num;
 
-		qdf_nbuf_update_radiotap(&(pdev->ppdu_info.rx_status),
-			mon_mpdu, sizeof(struct rx_pkt_tlvs));
+		if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status,
+					      mon_mpdu,
+					      qdf_nbuf_headroom(mon_mpdu))) {
+			DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
+			goto mon_deliver_fail;
+		}
+
 		pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
 						mon_mpdu,
 						&pdev->ppdu_info.rx_status);
@@ -1029,8 +1034,12 @@
 		pdev->ppdu_info.com_info.ppdu_id;
 
 	/* Apply the radio header to this dummy skb */
-	qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status,
-				 dummy_msdu, MAX_MONITOR_HEADER);
+	if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, dummy_msdu,
+				      qdf_nbuf_headroom(dummy_msdu))) {
+		DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
+		qdf_nbuf_free(dummy_msdu);
+		goto mon_deliver_non_std_fail;
+	}
 
 	/* deliver to the user layer application */
 	osif_rx_mon(pdev->monitor_vdev->osif_vdev,
diff --git a/dp/wifi3.0/dp_rx_mon_status.c b/dp/wifi3.0/dp_rx_mon_status.c
index 2c58d11..d8b733d 100644
--- a/dp/wifi3.0/dp_rx_mon_status.c
+++ b/dp/wifi3.0/dp_rx_mon_status.c
@@ -509,8 +509,12 @@
 	/* Only retain RX MSDU payload in the skb */
 	qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
 			   ppdu_info->msdu_info.payload_len);
-	qdf_nbuf_update_radiotap(&(pdev->ppdu_info.rx_status),
-				 nbuf, sizeof(struct rx_pkt_tlvs));
+	if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, nbuf,
+				      qdf_nbuf_headroom(nbuf))) {
+		DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
+		return 1;
+	}
+
 	pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
 					nbuf, NULL);
 	pdev->ppdu_info.rx_status.monitor_direct_used = 0;
diff --git a/dp/wifi3.0/dp_stats.c b/dp/wifi3.0/dp_stats.c
index 39f27fd..c291530 100644
--- a/dp/wifi3.0/dp_stats.c
+++ b/dp/wifi3.0/dp_stats.c
@@ -5380,6 +5380,8 @@
 		       pdev->stats.dropped.wifi_parse);
 	DP_PRINT_STATS("        mon_rx_drop = %d",
 		       pdev->stats.dropped.mon_rx_drop);
+	DP_PRINT_STATS("        mon_radiotap_update_err = %d",
+		       pdev->stats.dropped.mon_radiotap_update_err);
 	DP_PRINT_STATS("        mec_drop = %d",
 		       pdev->stats.rx.mec_drop.num);
 	DP_PRINT_STATS("	Bytes = %llu",