Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwspinlock: omap: Handle devm_pm_runtime_enable() errors

Although unlikely, devm_pm_runtime_enable() can fail due to memory
allocations. Without proper error handling, the subsequent
pm_runtime_resume_and_get() call may operate on incorrectly
initialized runtime PM state.

Add error handling to check the return value of
devm_pm_runtime_enable() and return on failure.

Fixes: 25f7d74d4514 ("hwspinlock: omap: Use devm_pm_runtime_enable() helper")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20251124104805.135-1-vulab@iscas.ac.cn
Signed-off-by: Kevin Hilman <khilman@baylibre.com>

authored by

Haotian Zhang and committed by
Kevin Hilman
3bd4edd6 5e2d6fa4

+3 -1
+3 -1
drivers/hwspinlock/omap_hwspinlock.c
··· 88 88 * make sure the module is enabled and clocked before reading 89 89 * the module SYSSTATUS register 90 90 */ 91 - devm_pm_runtime_enable(&pdev->dev); 91 + ret = devm_pm_runtime_enable(&pdev->dev); 92 + if (ret) 93 + return ret; 92 94 ret = pm_runtime_resume_and_get(&pdev->dev); 93 95 if (ret < 0) 94 96 return ret;