Răsfoiți Sursa

qcacld-3.0: Prevent possible NULL pointer dereference

The function wma_wake_event_piggybacked gets the pointer to pdev object
by calling cds_get_context with the respective module ID. This pdev
pointer is then passed on down the stack to CDP APIs where there are no
explicit NULL check to validate the same. In the case the pdev is NULL,
this can go on to cause a NULL pointer dereference.

Add a validation check on the PDEV pointer to avoid this.

Change-Id: Ifecd6853445c6df5e16e6310beb2bf7cbc6997a0
CRs-Fixed: 2524604
Sourav Mohapatra 5 ani în urmă
părinte
comite
5778c1db26
1 a modificat fișierele cu 6 adăugiri și 0 ștergeri
  1. 6 0
      core/wma/src/wma_features.c

+ 6 - 0
core/wma/src/wma_features.c

@@ -2422,6 +2422,11 @@ static int wma_wake_event_piggybacked(
 	}
 
 	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	if (!pdev) {
+		WMA_LOGE("Invalid pdev");
+		return -EINVAL;
+	}
+
 	bssid = wma_get_vdev_bssid
 		(wma->interfaces[event_param->fixed_param->vdev_id].vdev);
 	if (!bssid) {
@@ -2429,6 +2434,7 @@ static int wma_wake_event_piggybacked(
 			 __func__, event_param->fixed_param->vdev_id);
 		return 0;
 	}
+
 	peer = cdp_peer_find_by_addr(soc, pdev, bssid, &peer_id);
 	wake_reason = event_param->fixed_param->wake_reason;