Patch "firmware: qcom: scm: Fix __scm and waitq completion variable initialization" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    firmware: qcom: scm: Fix __scm and waitq completion variable initialization

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     firmware-qcom-scm-fix-__scm-and-waitq-completion-var.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 596adfcab831efdc233df811dc4c46f609944c84
Author: Mukesh Ojha <quic_mojha@xxxxxxxxxxx>
Date:   Thu Mar 21 20:54:02 2024 +0530

    firmware: qcom: scm: Fix __scm and waitq completion variable initialization
    
    [ Upstream commit 2e4955167ec5c04534cebea9e8273a907e7a75e1 ]
    
    It is possible qcom_scm_is_available() gives wrong indication that
    if __scm is initialized while __scm->dev is not and similar issue
    is also possible with __scm->waitq_comp.
    
    Fix this appropriately by the use of release barrier and read barrier
    that will make sure if __scm is initialized so, is all of its field
    variable.
    
    Fixes: d0f6fa7ba2d6 ("firmware: qcom: scm: Convert SCM to platform driver")
    Fixes: 6bf325992236 ("firmware: qcom: scm: Add wait-queue handling logic")
    Signed-off-by: Mukesh Ojha <quic_mojha@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/1711034642-22860-4-git-send-email-quic_mojha@xxxxxxxxxxx
    Signed-off-by: Bjorn Andersson <andersson@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index ca381cb2ee979..29c24578ad2bf 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -1713,7 +1713,7 @@ static int qcom_scm_qseecom_init(struct qcom_scm *scm)
  */
 bool qcom_scm_is_available(void)
 {
-	return !!__scm;
+	return !!READ_ONCE(__scm);
 }
 EXPORT_SYMBOL_GPL(qcom_scm_is_available);
 
@@ -1794,10 +1794,12 @@ static int qcom_scm_probe(struct platform_device *pdev)
 	if (!scm)
 		return -ENOMEM;
 
+	scm->dev = &pdev->dev;
 	ret = qcom_scm_find_dload_address(&pdev->dev, &scm->dload_mode_addr);
 	if (ret < 0)
 		return ret;
 
+	init_completion(&scm->waitq_comp);
 	mutex_init(&scm->scm_bw_lock);
 
 	scm->path = devm_of_icc_get(&pdev->dev, NULL);
@@ -1829,10 +1831,8 @@ static int qcom_scm_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	__scm = scm;
-	__scm->dev = &pdev->dev;
-
-	init_completion(&__scm->waitq_comp);
+	/* Let all above stores be available after this */
+	smp_store_release(&__scm, scm);
 
 	irq = platform_get_irq_optional(pdev, 0);
 	if (irq < 0) {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux