Skip to contentSkip to conversation

soc: qcom: smem: fix hwspinlock resource leak in probe error paths

PATCH Applied Haotian Zhang 3 participants 3 messages Oct 29, 2025 – Oct 30, 2025

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

PATCH 1/1 soc: qcom: smem: fix hwspinlock resource leak in probe error paths

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")
---
 drivers/soc/qcom/smem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/smem.c +1 -2
index cf425930539e..5d831b551c9a 100644
@@ -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;
 }
 
Signature · 1 line
2.50.1.windows.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Haotian Zhang

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")

---

Konrad

maintainer Applied
#2 lore raw
In reply to Haotian Zhang
Quoted 9 lines · Haotian Zhang

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.

[...]

Applied, thanks!

[1/1] soc: qcom: smem: fix hwspinlock resource leak in probe error paths

      commit: dc5db35073a19f6d3c30bea367b551c1a784ef8f

Best regards,

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