linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: ath: fix missing checks for bmi reads and writes
@ 2019-03-15  5:19 Kangjie Lu
  2019-03-15  5:24 ` Kalle Valo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kangjie Lu @ 2019-03-15  5:19 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Kalle Valo, David S. Miller, ath10k, linux-wireless,
	netdev, linux-kernel

ath10k_bmi_write32 and ath10k_bmi_read32 can fail. The fix
checks their statuses to avoid potential undefined behaviors.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/wireless/ath/ath10k/core.c | 40 ++++++++++++++++++++------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 835b8de92d55..1bb586f0040e 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -629,13 +629,20 @@ static void ath10k_send_suspend_complete(struct ath10k *ar)
 	complete(&ar->target_suspend);
 }
 
-static void ath10k_init_sdio(struct ath10k *ar)
+static int ath10k_init_sdio(struct ath10k *ar)
 {
+	int ret;
 	u32 param = 0;
 
-	ath10k_bmi_write32(ar, hi_mbox_io_block_sz, 256);
-	ath10k_bmi_write32(ar, hi_mbox_isr_yield_limit, 99);
-	ath10k_bmi_read32(ar, hi_acs_flags, &param);
+	ret = ath10k_bmi_write32(ar, hi_mbox_io_block_sz, 256);
+	if (ret)
+		return ret;
+	ret = ath10k_bmi_write32(ar, hi_mbox_isr_yield_limit, 99);
+	if (ret)
+		return ret;
+	ret = ath10k_bmi_read32(ar, hi_acs_flags, &param);
+	if (ret)
+		return ret;
 
 	/* Data transfer is not initiated, when reduced Tx completion
 	 * is used for SDIO. disable it until fixed
@@ -647,14 +654,22 @@ static void ath10k_init_sdio(struct ath10k *ar)
 	 */
 	param &= ~HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE;
 	param |= HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET;
-	ath10k_bmi_write32(ar, hi_acs_flags, param);
+	ret = ath10k_bmi_write32(ar, hi_acs_flags, param);
+	if (ret)
+		return ret;
 
 	/* Explicitly set fwlog prints to zero as target may turn it on
 	 * based on scratch registers.
 	 */
-	ath10k_bmi_read32(ar, hi_option_flag, &param);
+	ret = ath10k_bmi_read32(ar, hi_option_flag, &param);
+	if (ret)
+		return ret;
 	param |= HI_OPTION_DISABLE_DBGLOG;
-	ath10k_bmi_write32(ar, hi_option_flag, param);
+	ret = ath10k_bmi_write32(ar, hi_option_flag, param);
+	if (ret)
+		return ret;
+
+	return 0;
 }
 
 static int ath10k_init_configure_target(struct ath10k *ar)
@@ -2500,8 +2515,15 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
 		if (status)
 			goto err;
 
-		if (ar->hif.bus == ATH10K_BUS_SDIO)
-			ath10k_init_sdio(ar);
+		if (ar->hif.bus == ATH10K_BUS_SDIO) {
+			status = ath10k_init_sdio(ar);
+			if (status) {
+				ath10k_err(ar,
+					   "could not init HTC (%d)\n",
+					   status);
+				goto err;
+			}
+		}
 	}
 
 	ar->htc.htc_ops.target_send_suspend_complete =
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: ath: fix missing checks for bmi reads and writes
  2019-03-15  5:19 [PATCH] net: ath: fix missing checks for bmi reads and writes Kangjie Lu
@ 2019-03-15  5:24 ` Kalle Valo
  2019-04-26 11:51 ` Kalle Valo
  2019-09-23  8:18 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2019-03-15  5:24 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, David S. Miller, ath10k, linux-wireless, netdev, linux-kernel

Kangjie Lu <kjlu@umn.edu> writes:

> ath10k_bmi_write32 and ath10k_bmi_read32 can fail. The fix
> checks their statuses to avoid potential undefined behaviors.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

The title prefix should be "ath10k: ", I'll fix that.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: ath: fix missing checks for bmi reads and writes
  2019-03-15  5:19 [PATCH] net: ath: fix missing checks for bmi reads and writes Kangjie Lu
  2019-03-15  5:24 ` Kalle Valo
@ 2019-04-26 11:51 ` Kalle Valo
  2019-09-23  8:18 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2019-04-26 11:51 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: netdev, linux-wireless, linux-kernel, ath10k, pakki001, David S. Miller

Kangjie Lu <kjlu@umn.edu> writes:

> ath10k_bmi_write32 and ath10k_bmi_read32 can fail. The fix
> checks their statuses to avoid potential undefined behaviors.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

[...]

> @@ -2500,8 +2515,15 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
>  		if (status)
>  			goto err;
>  
> -		if (ar->hif.bus == ATH10K_BUS_SDIO)
> -			ath10k_init_sdio(ar);
> +		if (ar->hif.bus == ATH10K_BUS_SDIO) {
> +			status = ath10k_init_sdio(ar);
> +			if (status) {
> +				ath10k_err(ar,
> +					   "could not init HTC (%d)\n",
> +					   status);

I'll fix the warning message as well, we are not initialisating HTC
here.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: ath: fix missing checks for bmi reads and writes
  2019-03-15  5:19 [PATCH] net: ath: fix missing checks for bmi reads and writes Kangjie Lu
  2019-03-15  5:24 ` Kalle Valo
  2019-04-26 11:51 ` Kalle Valo
@ 2019-09-23  8:18 ` Kalle Valo
  2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2019-09-23  8:18 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: kjlu, pakki001, David S. Miller, ath10k, linux-wireless, netdev,
	linux-kernel

Kangjie Lu <kjlu@umn.edu> wrote:

> ath10k_bmi_write32 and ath10k_bmi_read32 can fail. The fix
> checks their statuses to avoid potential undefined behaviors.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

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

8da96730331d ath10k: fix missing checks for bmi reads and writes

-- 
https://patchwork.kernel.org/patch/10854069/

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-23  8:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15  5:19 [PATCH] net: ath: fix missing checks for bmi reads and writes Kangjie Lu
2019-03-15  5:24 ` Kalle Valo
2019-04-26 11:51 ` Kalle Valo
2019-09-23  8:18 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).