Bläddra i källkod

qcacmn: Validate pktlog handle

Add a NULL check to validate pktlog handle
before dereferencing it.

Change-Id: I3ea56b60460c5c2cfae0fff97f0721068156cf4a
CRs-Fixed: 2468506
Venkata Sharath Chandra Manchala 5 år sedan
förälder
incheckning
ff4d3f79f1
1 ändrade filer med 12 tillägg och 2 borttagningar
  1. 12 2
      utils/pktlog/pktlog_internal.c

+ 12 - 2
utils/pktlog/pktlog_internal.c

@@ -1413,6 +1413,11 @@ int process_rx_desc_remote(void *pdev, void *data)
 	struct ath_pktlog_info *pl_info;
 	qdf_nbuf_t log_nbuf = (qdf_nbuf_t)data;
 
+	if (!pl_dev) {
+		qdf_err("Pktlog handle is NULL");
+		return -EINVAL;
+	}
+
 	pl_info = pl_dev->pl_info;
 	qdf_mem_zero(&pl_hdr, sizeof(pl_hdr));
 	pl_hdr.flags = (1 << PKTLOG_FLG_FRM_TYPE_REMOTE_S);
@@ -1427,7 +1432,7 @@ int process_rx_desc_remote(void *pdev, void *data)
 	if (!rxstat_log.rx_desc) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
 				"%s: Rx descriptor is NULL", __func__);
-		return -EFAULT;
+		return -EINVAL;
 	}
 
 	qdf_mem_copy(rxstat_log.rx_desc, qdf_nbuf_data(log_nbuf), pl_hdr.size);
@@ -1446,6 +1451,11 @@ process_pktlog_lite(void *context, void *log_data, uint16_t log_type)
 	size_t log_size;
 	qdf_nbuf_t log_nbuf = (qdf_nbuf_t)log_data;
 
+	if (!pl_dev) {
+		qdf_err("Pktlog handle is NULL");
+		return -EINVAL;
+	}
+
 	pl_info = pl_dev->pl_info;
 	qdf_mem_zero(&pl_hdr, sizeof(pl_hdr));
 	pl_hdr.flags = (1 << PKTLOG_FLG_FRM_TYPE_REMOTE_S);
@@ -1459,7 +1469,7 @@ process_pktlog_lite(void *context, void *log_data, uint16_t log_type)
 	if (!rxstat_log.rx_desc) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
 			"%s: Rx descriptor is NULL", __func__);
-		return -EFAULT;
+		return -EINVAL;
 	}
 
 	qdf_mem_copy(rxstat_log.rx_desc, qdf_nbuf_data(log_nbuf), pl_hdr.size);