coresight: Check runtime PM resume result
PATCH v2 1/1 coresight: Check runtime PM resume result
coresight_get_ref() ignores the return value of pm_runtime_get_sync() and reports success even when runtime resume fails. A path is then built and the CoreSight device may be accessed while it remains powered off.
Use pm_runtime_resume_and_get() so a failed resume is reported and its runtime PM usage reference is rolled back. Drop the module and device references acquired before the resume attempt when it fails.
---
Changes in v2:
- Point Fixes: at commit 32b0707a4182, which introduced coresight_get_ref() with the unchecked pm_runtime_get_sync() (Anshuman Khandual)
- Switch to my oss.patchbox address
v1: https://lore.kernel.org/all/[email protected]/
drivers/hwtracing/coresight/coresight-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-core.c +5 -1
@@ -843,7 +843,11 @@ static bool coresight_get_ref(struct coresight_device *csdev) goto err_module;/* Make sure the device is powered on */ -pm_runtime_get_sync (parent); +if (pm_runtime_resume_and_get (parent) <0 ) { +module_put (drv->owner); + goto err_module; + } +return true; err_module:
base-commit: f0100363d8c374bd8e9ea7c9ba02744f0b802ca4
Signature · 1 line
2.43.0
Leo Yan
reviewerdrivers/hwtracing/coresight/coresight-core.c static bool coresight_get_ref(struct coresight_device *csdev) · line 850
Quoted 10 lines · Yuho Choi
drivers/hwtracing/coresight/coresight-core.c +5
-1@@ -843,7 +843,11 @@ static bool coresight_get_ref(struct coresight_device *csdev) goto err_module;/* Make sure the device is powered on */ -pm_runtime_get_sync (parent); +if (pm_runtime_resume_and_get (parent) <0 ) { +module_put (drv->owner); + goto err_module; + } +
There is already a patch that does something similar and fixes the same errors across the CoreSight folder. See:
Quoted 3 lines · Leo Yan
There is already a patch that does something similar and fixes the same errors across the CoreSight folder. See:
Thanks for pointing out the existing patch!