Skip to contentSkip to conversation

firmware: qcom: uefisecapp: Fix deadlock in qcuefi_acquire()

PATCH Applied Dan Carpenter 3 participants 3 messages Aug 29, 2024 – Aug 31, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: qcom: uefisecapp: Fix deadlock in qcuefi_acquire()

If the __qcuefi pointer is not set, then in the original code, we would hold onto the lock. That means that if we tried to set it later, then it would cause a deadlock. Drop the lock on the error path. That's what all the callers are expecting.

Fixes 759e7a2b62eb ("firmware: Add support for Qualcomm UEFI Secure Application")
---
 drivers/firmware/qcom/qcom_qseecom_uefisecapp.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/firmware/qcom/qcom_qseecom_uefisecapp.c +4 -0
index 6fefa4fe80e8..447246bd04be 100644
@@ -715,6 +715,10 @@ static int qcuefi_set_reference(struct qcuefi_client *qcuefi)
 static struct qcuefi_client *qcuefi_acquire(void)
 {
 	mutex_lock(&__qcuefi_lock);
+	if (!__qcuefi) {
+		mutex_unlock(&__qcuefi_lock);
+		return NULL;
+	}
 	return __qcuefi;
 }
 
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dan Carpenter

If the __qcuefi pointer is not set, then in the original code, we would hold onto the lock. That means that if we tried to set it later, then it would cause a deadlock. Drop the lock on the error path. That's what all the callers are expecting.

Fixes 759e7a2b62eb ("firmware: Add support for Qualcomm UEFI Secure Application")
---
 drivers/firmware/qcom/qcom_qseecom_uefisecapp.c | 4 ++++
 1 file changed, 4 insertions(+)
Signature · 2 lines
With best wishes
Dmitry
maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

If the __qcuefi pointer is not set, then in the original code, we would hold onto the lock. That means that if we tried to set it later, then it would cause a deadlock. Drop the lock on the error path. That's what all the callers are expecting.

Applied, thanks!

[1/1] firmware: qcom: uefisecapp: Fix deadlock in qcuefi_acquire()

      commit: db213b0cfe3268d8b1d382b3bcc999c687a2567f

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>