diff options
| author | Zhang Qian <zhangq@codeaurora.org> | 2017-03-23 10:50:22 +0800 |
|---|---|---|
| committer | Sandeep Puligilla <spuligil@codeaurora.org> | 2017-04-06 14:11:20 -0700 |
| commit | 9af8c2d22c4ff1d59975cf5ef6e873bfbb7cb909 (patch) | |
| tree | 76ad99c579044d2554ab826ab151776a7b16a2ba | |
| parent | e3fe3e7178232951efa11166a08b5234007c696b (diff) | |
qcacld-3.0: Fix resource leak in __ol_transfer_bin_file
qcacld-2.0 to qcacld-3.0 propagation
If data was NULL in fw_entry, fw_entry should be released before return.
Otherwise there will be resource leakage.
Change-Id: I0a72f6bd74f349baf1028aed1f9988b188cda1b6
CRs-fixed: 1111115
| -rw-r--r-- | core/bmi/src/ol_fw.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/core/bmi/src/ol_fw.c b/core/bmi/src/ol_fw.c index fd0e364f81cd..08cc59a2988a 100644 --- a/core/bmi/src/ol_fw.c +++ b/core/bmi/src/ol_fw.c @@ -279,7 +279,8 @@ __ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, if (!fw_entry || !fw_entry->data) { BMI_ERR("Invalid fw_entries"); - return QDF_STATUS_E_FAILURE; + status = -ENOENT; + goto release_fw; } fw_entry_size = fw_entry->size; @@ -289,7 +290,7 @@ __ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, if (ol_check_fw_hash(qdf_dev->dev, fw_entry->data, fw_entry_size, file)) { BMI_ERR("Hash Check failed for file:%s", filename); - status = QDF_STATUS_E_FAILURE; + status = -EINVAL; goto end; } #endif @@ -302,7 +303,7 @@ __ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, if (!temp_eeprom) { BMI_ERR("%s: Memory allocation failed", __func__); release_firmware(fw_entry); - return QDF_STATUS_E_NOMEM; + return -ENOMEM; } qdf_mem_copy(temp_eeprom, (uint8_t *) fw_entry->data, @@ -363,7 +364,7 @@ __ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, if (fw_entry_size < sizeof(SIGN_HEADER_T)) { BMI_ERR("Invalid binary size %d", fw_entry_size); - status = QDF_STATUS_E_FAILURE; + status = -EINVAL; goto end; } @@ -379,7 +380,7 @@ __ol_transfer_bin_file(struct ol_context *ol_ctx, ATH_BIN_FILE file, sizeof(SIGN_HEADER_T), ol_ctx); if (status != EOK) { BMI_ERR("unable to start sign stream"); - status = QDF_STATUS_E_FAILURE; + status = -EINVAL; goto end; } @@ -429,17 +430,15 @@ end: if (temp_eeprom) qdf_mem_free(temp_eeprom); - if (status != EOK) { - BMI_ERR("%s, BMI operation failed: %d", __func__, __LINE__); +release_fw: + if (fw_entry) release_firmware(fw_entry); - return QDF_STATUS_E_FAILURE; - } - - release_firmware(fw_entry); - - BMI_INFO("transferring file: %s size %d bytes done!", - (filename != NULL) ? filename : " ", fw_entry_size); + if (status != EOK) + BMI_ERR("%s, BMI operation failed: %d", __func__, __LINE__); + else + BMI_INFO("transferring file: %s size %d bytes done!", + (filename != NULL) ? filename : " ", fw_entry_size); return status; } |
