Bladeren bron

qcacld-3.0: Fix static analysis issues in wma

Resolve static analysis issues - NULL pointer dereference and array
boundary checking.

Change-Id: Ia509cdb9b61d4f7b86175e3b3ec6d4691fc1f7a2
CRs-Fixed: 2162260
Yun Park 7 jaren geleden
bovenliggende
commit
01a45f7d33
3 gewijzigde bestanden met toevoegingen van 14 en 7 verwijderingen
  1. 3 6
      core/wma/src/wma_mgmt.c
  2. 5 0
      core/wma/src/wma_scan_roam.c
  3. 6 1
      core/wma/src/wma_utils.c

+ 3 - 6
core/wma/src/wma_mgmt.c

@@ -3499,8 +3499,7 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle,
 				    should_drop = true;
 			}
 		}
-		*cdp_peer_last_assoc_received(soc, peer) =
-				qdf_get_system_timestamp();
+		*ptr = qdf_get_system_timestamp();
 		break;
 	case IEEE80211_FC0_SUBTYPE_DISASSOC:
 		ptr = cdp_peer_last_disassoc_received(soc, peer);
@@ -3515,8 +3514,7 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle,
 				    should_drop = true;
 			}
 		}
-		*cdp_peer_last_disassoc_received(soc, peer) =
-				qdf_get_system_timestamp();
+		*ptr = qdf_get_system_timestamp();
 		break;
 	case IEEE80211_FC0_SUBTYPE_DEAUTH:
 		ptr = cdp_peer_last_deauth_received(soc, peer);
@@ -3531,8 +3529,7 @@ static bool wma_is_pkt_drop_candidate(tp_wma_handle wma_handle,
 				    should_drop = true;
 			}
 		}
-		*cdp_peer_last_deauth_received(soc, peer) =
-				qdf_get_system_timestamp();
+		*ptr = qdf_get_system_timestamp();
 		break;
 	default:
 		break;

+ 5 - 0
core/wma/src/wma_scan_roam.c

@@ -6112,6 +6112,11 @@ QDF_STATUS wma_get_scan_id(uint32_t *scan_id)
 		return QDF_STATUS_E_FAULT;
 	}
 
+	if (!wma) {
+		WMA_LOGE("%s: wma handle is NULL", __func__);
+		return QDF_STATUS_E_INVAL;
+	}
+
 #ifdef NAPIER_SCAN
 	*scan_id = ucfg_scan_get_scan_id(wma->psoc);
 #else

+ 6 - 1
core/wma/src/wma_utils.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -4666,6 +4666,11 @@ bool wma_is_service_enabled(WMI_SERVICE service_type)
 		return false;
 	}
 
+	if (service_type >= WMI_MAX_SERVICE) {
+		WMA_LOGE("%s: Invalid service type %d", __func__, service_type);
+		return false;
+	}
+
 	return WMI_SERVICE_IS_ENABLED(wma->wmi_service_bitmap, service_type);
 }