Skip to content

Commit 2e49551

Browse files
Mukesh Ojhaandersson
authored andcommitted
firmware: qcom: scm: Fix __scm and waitq completion variable initialization
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: d0f6fa7 ("firmware: qcom: scm: Convert SCM to platform driver") Fixes: 6bf3259 ("firmware: qcom: scm: Add wait-queue handling logic") Signed-off-by: Mukesh Ojha <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 398a4c5 commit 2e49551

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/firmware/qcom/qcom_scm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ static int qcom_scm_qseecom_init(struct qcom_scm *scm)
17371737
*/
17381738
bool qcom_scm_is_available(void)
17391739
{
1740-
return !!__scm;
1740+
return !!READ_ONCE(__scm);
17411741
}
17421742
EXPORT_SYMBOL_GPL(qcom_scm_is_available);
17431743

@@ -1818,10 +1818,12 @@ static int qcom_scm_probe(struct platform_device *pdev)
18181818
if (!scm)
18191819
return -ENOMEM;
18201820

1821+
scm->dev = &pdev->dev;
18211822
ret = qcom_scm_find_dload_address(&pdev->dev, &scm->dload_mode_addr);
18221823
if (ret < 0)
18231824
return ret;
18241825

1826+
init_completion(&scm->waitq_comp);
18251827
mutex_init(&scm->scm_bw_lock);
18261828

18271829
scm->path = devm_of_icc_get(&pdev->dev, NULL);
@@ -1853,10 +1855,8 @@ static int qcom_scm_probe(struct platform_device *pdev)
18531855
if (ret)
18541856
return ret;
18551857

1856-
__scm = scm;
1857-
__scm->dev = &pdev->dev;
1858-
1859-
init_completion(&__scm->waitq_comp);
1858+
/* Let all above stores be available after this */
1859+
smp_store_release(&__scm, scm);
18601860

18611861
irq = platform_get_irq_optional(pdev, 0);
18621862
if (irq < 0) {

0 commit comments

Comments
 (0)