summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorOrhan K AKYILDIZ <oka@codeaurora.org>2017-10-24 15:53:41 -0700
committersnandini <snandini@codeaurora.org>2017-10-26 17:47:30 -0700
commit6bd48f118ab242f7eb1f76f7caa0476a5e016478 (patch)
tree40990d98ddbe7e98613a3c21a9361421d88aeef4 /utils
parentfa601a66eb267d88c0a99d67045499ee5312c298 (diff)
downloadqca-wfi-host-cmn-6bd48f118ab242f7eb1f76f7caa0476a5e016478.tar.gz
qcacmn: Add sanity check for pktlog msgs
Add sanity check for pktlog messages, as we have seen a single case of inconsisten nbuf. Assert if fails. Change-Id: I6a076c4dfaa2ff8e1972dd795cadeca1302b2c0e CRs-Fixed: 2131952
Diffstat (limited to 'utils')
-rw-r--r--utils/pktlog/pktlog_ac.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/utils/pktlog/pktlog_ac.c b/utils/pktlog/pktlog_ac.c
index df03e0178..ca4962e43 100644
--- a/utils/pktlog/pktlog_ac.c
+++ b/utils/pktlog/pktlog_ac.c
@@ -741,6 +741,17 @@ void pktlog_process_fw_msg(uint32_t *buff)
}
#if defined(QCA_WIFI_3_0_ADRASTEA)
+static inline int pktlog_nbuf_check_sanity(qdf_nbuf_t nbuf)
+{
+ int rc = 0; /* sane */
+
+ if ((!nbuf) ||
+ (nbuf->data < nbuf->head) ||
+ ((nbuf->data + skb_headlen(nbuf)) > skb_end_pointer(nbuf)))
+ rc = -EINVAL;
+
+ return rc;
+}
/**
* pktlog_t2h_msg_handler() - Target to host message handler
* @context: pdev context
@@ -754,6 +765,15 @@ static void pktlog_t2h_msg_handler(void *context, HTC_PACKET *pkt)
qdf_nbuf_t pktlog_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
uint32_t *msg_word;
+ /* check for sanity of the packet, have seen corrupted pkts */
+ if (pktlog_nbuf_check_sanity(pktlog_t2h_msg)) {
+ qdf_print("%s: packet 0x%p corrupted? Leaking...",
+ __func__, pktlog_t2h_msg);
+ /* do not free; may crash! */
+ QDF_ASSERT(0);
+ return;
+ }
+
/* check for successful message reception */
if (pkt->Status != QDF_STATUS_SUCCESS) {
if (pkt->Status != QDF_STATUS_E_CANCELED)