Commit 342b6194 authored by Alex Dewar's avatar Alex Dewar Committed by Kalle Valo

ath11k: return error if firmware request fails

In ath11k_qmi_prepare_bdf_download(), ath11k_core_firmware_request() is
called, but the returned pointer is not checked for errors. Rather the
variable ret (which will always be zero) is checked by mistake. Fix
this and replace the various gotos with simple returns for clarity.

While we are at it, move the call to memset, as variable bd is not used
on all code paths.

Fixes: 7b57b2dd ("ath11k: create a common function to request all firmware files")
Signed-off-by: default avatarAlex Dewar <alex.dewar90@gmail.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200825143040.233619-1-alex.dewar90@gmail.com
parent 72cdab80
...@@ -1868,16 +1868,16 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type, ...@@ -1868,16 +1868,16 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
const struct firmware *fw_entry; const struct firmware *fw_entry;
struct ath11k_board_data bd; struct ath11k_board_data bd;
u32 fw_size; u32 fw_size;
int ret = 0; int ret;
memset(&bd, 0, sizeof(bd));
switch (type) { switch (type) {
case ATH11K_QMI_FILE_TYPE_BDF_GOLDEN: case ATH11K_QMI_FILE_TYPE_BDF_GOLDEN:
memset(&bd, 0, sizeof(bd));
ret = ath11k_core_fetch_bdf(ab, &bd); ret = ath11k_core_fetch_bdf(ab, &bd);
if (ret) { if (ret) {
ath11k_warn(ab, "qmi failed to load BDF\n"); ath11k_warn(ab, "qmi failed to load BDF\n");
goto out; return ret;
} }
fw_size = min_t(u32, ab->hw_params.fw.board_size, bd.len); fw_size = min_t(u32, ab->hw_params.fw.board_size, bd.len);
...@@ -1886,10 +1886,11 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type, ...@@ -1886,10 +1886,11 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
break; break;
case ATH11K_QMI_FILE_TYPE_CALDATA: case ATH11K_QMI_FILE_TYPE_CALDATA:
fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE); fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE);
if (ret) { if (IS_ERR(fw_entry)) {
ret = PTR_ERR(fw_entry);
ath11k_warn(ab, "failed to load %s: %d\n", ath11k_warn(ab, "failed to load %s: %d\n",
ATH11K_DEFAULT_CAL_FILE, ret); ATH11K_DEFAULT_CAL_FILE, ret);
goto out; return ret;
} }
fw_size = min_t(u32, ab->hw_params.fw.board_size, fw_size = min_t(u32, ab->hw_params.fw.board_size,
...@@ -1901,14 +1902,11 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type, ...@@ -1901,14 +1902,11 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
release_firmware(fw_entry); release_firmware(fw_entry);
break; break;
default: default:
ret = -EINVAL; return -EINVAL;
goto out;
} }
req->total_size = fw_size; req->total_size = fw_size;
return 0;
out:
return ret;
} }
static int ath11k_qmi_load_bdf_fixed_addr(struct ath11k_base *ab) static int ath11k_qmi_load_bdf_fixed_addr(struct ath11k_base *ab)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment