]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
firmware: qcom: uefisecapp: Fix deadlock in qcuefi_acquire()
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 29 Aug 2024 19:23:04 +0000 (22:23 +0300)
committerBjorn Andersson <andersson@kernel.org>
Sat, 31 Aug 2024 03:17:50 +0000 (22:17 -0500)
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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/19829bc4-1b6f-47f7-847a-e90c25749e40@stanley.mountain
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/firmware/qcom/qcom_qseecom_uefisecapp.c

index 6fefa4fe80e86f39a179ccd93b8ab18d49fab309..447246bd04be3fe13d19bd81578e9a23310d027b 100644 (file)
@@ -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;
 }