From dd2178d1464d707f3a8d0c3441c779918a6fac41 Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Wed, 2 May 2018 09:53:12 -0700 Subject: [PATCH] qcacld-3.0: Fix off-by-one errors in PMO The following PMO functions have been identified as having off-by-one logic errors. Address these errors. * pmo_register_resume_handler * pmo_register_suspend_handler * pmo_unregister_resume_handler * pmo_suspend_all_components Change-Id: I6a328fc24ae6a575ef56cf9532133eb666e0dc8c CRs-Fixed: 2232388 --- .../pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c b/components/pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c index dc0d7bfc34..9e834b9938 100644 --- a/components/pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c +++ b/components/pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c @@ -337,7 +337,7 @@ QDF_STATUS pmo_register_suspend_handler( goto out; } - if (id > WLAN_UMAC_MAX_COMPONENTS || id < 0) { + if (id < 0 || id >= WLAN_UMAC_MAX_COMPONENTS) { pmo_err("component id: %d is %s then valid components id", id, id < 0 ? "Less" : "More"); status = QDF_STATUS_E_FAILURE; @@ -370,7 +370,7 @@ QDF_STATUS pmo_unregister_suspend_handler( goto out; } - if (id >= WLAN_UMAC_MAX_COMPONENTS || id < 0) { + if (id < 0 || id >= WLAN_UMAC_MAX_COMPONENTS) { pmo_err("component id: %d is %s then valid components id", id, id < 0 ? "Less" : "More"); status = QDF_STATUS_E_FAILURE; @@ -409,7 +409,7 @@ QDF_STATUS pmo_register_resume_handler( goto out; } - if (id > WLAN_UMAC_MAX_COMPONENTS || id < 0) { + if (id < 0 || id >= WLAN_UMAC_MAX_COMPONENTS) { pmo_err("component id: %d is %s then valid components id", id, id < 0 ? "Less" : "More"); status = QDF_STATUS_E_FAILURE; @@ -441,7 +441,7 @@ QDF_STATUS pmo_unregister_resume_handler( goto out; } - if (id > WLAN_UMAC_MAX_COMPONENTS || id < 0) { + if (id < 0 || id >= WLAN_UMAC_MAX_COMPONENTS) { pmo_err("component id: %d is %s then valid components id", id, id < 0 ? "Less" : "More"); status = QDF_STATUS_E_FAILURE; @@ -470,7 +470,7 @@ QDF_STATUS pmo_suspend_all_components(struct wlan_objmgr_psoc *psoc, QDF_STATUS status = QDF_STATUS_SUCCESS; QDF_STATUS resume_status; struct wlan_pmo_ctx *pmo_ctx; - uint8_t i; + int i; pmo_psoc_suspend_handler handler; void *arg; @@ -521,7 +521,7 @@ suspend_recovery: pmo_fatal("Non-recoverable failure occurred!"); pmo_fatal("component %d failed to resume; status: %d", i, resume_status); - QDF_BUG(0); + QDF_DEBUG_PANIC(); } }