Skip to contentSkip to conversation

wifi: ath12k: Fix locking in error paths

PATCH Applied Bart Van Assche 3 participants 5 messages Feb 6, 2025 – Feb 11, 2025 Qualcomm ATH12K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: ath12k: Fix locking in error paths

If ag->mutex has been locked, unlock it before returning. If it has not been locked, do not unlock it before returning. These bugs have been detected by the Clang thread-safety analyzer.

Cc Karthikeyan Periyasamy <[email protected]>
Cc Jeff Johnson <[email protected]>
Fixes ee146e11b4d9 ("wifi: ath12k: refactor core start based on hardware group")
---
 drivers/net/wireless/ath/ath12k/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/core.c +3 -1
index 0606116d6b9c..212cd935e60a 100644
@@ -1122,16 +1122,18 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab)
 		ath12k_core_stop(ab);
 		mutex_unlock(&ab->core_lock);
 	}
+	mutex_unlock(&ag->mutex);
 	goto exit;
 
 err_dp_free:
 	ath12k_dp_free(ab);
 	mutex_unlock(&ab->core_lock);
+	mutex_unlock(&ag->mutex);
+
 err_firmware_stop:
 	ath12k_qmi_firmware_stop(ab);
 
 exit:
-	mutex_unlock(&ag->mutex);
 	return ret;
 }
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Bart Van Assche

If ag->mutex has been locked, unlock it before returning. If it has not been locked, do not unlock it before returning. These bugs have been detected by the Clang thread-safety analyzer.

Cc Karthikeyan Periyasamy<[email protected]>
Cc Jeff Johnson<[email protected]>
Fixes ee146e11b4d9 ("wifi: ath12k: refactor core start based on hardware group")

---

Signature · 1 line
Aditya
#2 lore raw
In reply to Bart Van Assche
Quoted 26 lines · Bart Van Assche

If ag->mutex has been locked, unlock it before returning. If it has not been locked, do not unlock it before returning. These bugs have been detected by the Clang thread-safety analyzer.

Cc Karthikeyan Periyasamy <[email protected]>
Cc Jeff Johnson <[email protected]>
Fixes ee146e11b4d9 ("wifi: ath12k: refactor core start based on hardware group")
---
 drivers/net/wireless/ath/ath12k/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/core.c +1 -0
index 0606116d6b9c..212cd935e60a 100644
@@ -1122,16 +1122,18 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab)
 		ath12k_core_stop(ab);
 		mutex_unlock(&ab->core_lock);
 	}
+	mutex_unlock(&ag->mutex);
 	goto exit;
 
 err_dp_free:
 	ath12k_dp_free(ab);
 	mutex_unlock(&ab->core_lock);

drivers/net/wireless/ath/ath12k/core.c int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) · line 1139

Quoted 10 lines
drivers/net/wireless/ath/ath12k/core.c +2 -1
+	mutex_unlock(&ag->mutex);
+
 err_firmware_stop:
 	ath12k_qmi_firmware_stop(ab);
 
 exit:
-	mutex_unlock(&ag->mutex);
 	return ret;
 }
 

I made the subject a bit more descriptive in the pending branch:
https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git/commit/?h=pending&id=09a2421b6e5f617cfbeab906fa8037dda4aa95b8

/jeff

#3 lore raw
Quoted 32 lines · Jeff Johnson
Quoted 31 lines · Bart Van Assche

If ag->mutex has been locked, unlock it before returning. If it has not been locked, do not unlock it before returning. These bugs have been detected by the Clang thread-safety analyzer.

Cc Karthikeyan Periyasamy <[email protected]>
Cc Jeff Johnson <[email protected]>
Fixes ee146e11b4d9 ("wifi: ath12k: refactor core start based on hardware group")
---
  drivers/net/wireless/ath/ath12k/core.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/core.c +3 -0
index 0606116d6b9c..212cd935e60a 100644
@@ -1122,16 +1122,18 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab)
  		ath12k_core_stop(ab);
  		mutex_unlock(&ab->core_lock);
  	}
+	mutex_unlock(&ag->mutex);
  	goto exit;
 
  err_dp_free:
  	ath12k_dp_free(ab);
  	mutex_unlock(&ab->core_lock);
+	mutex_unlock(&ag->mutex);
+
  err_firmware_stop:
  	ath12k_qmi_firmware_stop(ab);
 
Quoted 8 lines

drivers/net/wireless/ath/ath12k/core.c int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) · line 1139

Quoted 5 lines
drivers/net/wireless/ath/ath12k/core.c +0 -1
  exit:
-	mutex_unlock(&ag->mutex);
  	return ret;
  }
 

I made the subject a bit more descriptive in the pending branch:
https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git/commit/?h=pending&id=09a2421b6e5f617cfbeab906fa8037dda4aa95b8

Better now, thanks.

Signature · 1 line
Aditya
Applied
#4 lore raw
In reply to Bart Van Assche
Quoted 5 lines · Bart Van Assche

If ag->mutex has been locked, unlock it before returning. If it has not been locked, do not unlock it before returning. These bugs have been detected by the Clang thread-safety analyzer.

Applied, thanks!

[1/1] wifi: ath12k: Fix locking in error paths

      commit: b9c7299a3341a737622e4de45b9c27e60ad01e3b

Best regards,

Signature · 1 line
Jeff Johnson <[email protected]>