]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
soc: qcom: smem: fix hwspinlock resource leak in probe error paths
authorHaotian Zhang <vulab@iscas.ac.cn>
Wed, 29 Oct 2025 02:27:33 +0000 (10:27 +0800)
committerBjorn Andersson <andersson@kernel.org>
Wed, 29 Oct 2025 16:46:57 +0000 (11:46 -0500)
The hwspinlock acquired via hwspin_lock_request_specific() is not
released on several error paths. This results in resource leakage
when probe fails.

Switch to devm_hwspin_lock_request_specific() to automatically
handle cleanup on probe failure. Remove the manual hwspin_lock_free()
in qcom_smem_remove() as devm handles it automatically.

Fixes: 20bb6c9de1b7 ("soc: qcom: smem: map only partitions used by local HOST")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20251029022733.255-1-vulab@iscas.ac.cn
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/soc/qcom/smem.c

index c4c45f15dca4fb14f97df4ad494c1189e4f098bd..f1d1b5aa5e4db6e1f3befa84f387ad060ffb8366 100644 (file)
@@ -1190,7 +1190,7 @@ static int qcom_smem_probe(struct platform_device *pdev)
                return dev_err_probe(&pdev->dev, hwlock_id,
                                     "failed to retrieve hwlock\n");
 
-       smem->hwlock = hwspin_lock_request_specific(hwlock_id);
+       smem->hwlock = devm_hwspin_lock_request_specific(&pdev->dev, hwlock_id);
        if (!smem->hwlock)
                return -ENXIO;
 
@@ -1243,7 +1243,6 @@ static void qcom_smem_remove(struct platform_device *pdev)
 {
        platform_device_unregister(__smem->socinfo);
 
-       hwspin_lock_free(__smem->hwlock);
        __smem = NULL;
 }