Browse Source

qcacld-3.0: Add check for zero before division

Currently in function pmo_core_config_modulated_dtim there is a possible
scenario of a division by zero. The parameter dtim period can have zero
value.

Add a check before performing the operation.

Change-Id: Ida4a798e5c7914966db25bd188821a75caaf4353
CRs-Fixed: 2432010
Sourav Mohapatra 6 years ago
parent
commit
618f208d24
1 changed files with 12 additions and 2 deletions
  1. 12 2
      components/pmo/core/src/wlan_pmo_suspend_resume.c

+ 12 - 2
components/pmo/core/src/wlan_pmo_suspend_resume.c

@@ -1464,6 +1464,7 @@ QDF_STATUS pmo_core_config_modulated_dtim(struct wlan_objmgr_vdev *vdev,
 	uint32_t max_mod_dtim;
 	QDF_STATUS status;
 	uint8_t vdev_id;
+	uint32_t max_dtim;
 
 	pmo_enter();
 
@@ -1481,9 +1482,18 @@ QDF_STATUS pmo_core_config_modulated_dtim(struct wlan_objmgr_vdev *vdev,
 	if (!beacon_interval_mod)
 		beacon_interval_mod = 1;
 
-	max_mod_dtim = psoc_cfg->sta_max_li_mod_dtim /
-		(pmo_core_get_vdev_dtim_period(vdev)
+	max_dtim = (pmo_core_get_vdev_dtim_period(vdev)
 		 * beacon_interval_mod);
+
+	if (!max_dtim) {
+		pmo_err("Invalid dtim period");
+		pmo_vdev_put_ref(vdev);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	max_mod_dtim = psoc_cfg->sta_max_li_mod_dtim /
+		max_dtim;
+
 	if (!max_mod_dtim)
 		max_mod_dtim = 1;