Skip to contentSkip to conversation

ath11k: return error if firmware request fails

PATCH In review Alex Dewar 2 participants 3 messages Aug 25, 2020 – Aug 27, 2020

Subsystems (3)
lore
Share & tools
lore

Alex Dewar

author
#0 lore raw

PATCH 1/1 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 7b57b2ddec21 ("ath11k: create a common function to request all firmware files")
---
 drivers/net/wireless/ath/ath11k/qmi.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/wireless/ath/ath11k/qmi.c +9 -11
index 91134510364c..b906b50ee57e 100644
@@ -1868,16 +1868,16 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
 	const struct firmware *fw_entry;
 	struct ath11k_board_data bd;
 	u32 fw_size;
-	int ret = 0;
-
-	memset(&bd, 0, sizeof(bd));
+	int ret;
 
 	switch (type) {
 	case ATH11K_QMI_FILE_TYPE_BDF_GOLDEN:
+		memset(&bd, 0, sizeof(bd));
+
 		ret = ath11k_core_fetch_bdf(ab, &bd);
 		if (ret) {
 			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);
@@ -1886,10 +1886,11 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
 		break;
 	case ATH11K_QMI_FILE_TYPE_CALDATA:
 		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_DEFAULT_CAL_FILE, ret);
-			goto out;
+			return ret;
 		}
 
 		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,
 		release_firmware(fw_entry);
 		break;
 	default:
-		ret = -EINVAL;
-		goto out;
+		return -EINVAL;
 	}
 
 	req->total_size = fw_size;
-
-out:
-	return ret;
+	return 0;
 }
 
 static int ath11k_qmi_load_bdf_fixed_addr(struct ath11k_base *ab)
Signature · 7 lines
2.28.0


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#1 lore raw
Quoted 11 lines · Alex Dewar

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 7b57b2ddec21 ("ath11k: create a common function to request all firmware files")

Patch applied to ath-next branch of ath.git, thanks.

342b6194a75b ath11k: return error if firmware request fails

Signature · 3 lines
https://patchwork.kernel.org/patch/11735787/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#2 lore raw
In reply to Alex Dewar
Quoted 11 lines · Alex Dewar

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 7b57b2ddec21 ("ath11k: create a common function to request all firmware files")

Patch applied to ath-next branch of ath.git, thanks.

342b6194a75b ath11k: return error if firmware request fails

Signature · 9 lines
https://patchwork.kernel.org/patch/11735787/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k