media: qcom: iris: initialize managed OPP pointer
Subsystems (4)
PATCH 1/1 media: qcom: iris: initialize managed OPP pointer
Initialize the __free(put_opp) managed OPP pointer to NULL.
This ensures the cleanup handler always sees a defined value and avoids leaving the managed pointer uninitialized before assignment.
--- drivers/media/platform/qcom/iris/iris_resources.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_resources.c +1 -1
@@ -61,7 +61,7 @@ int iris_unset_icc_bw(struct iris_core *core)int iris_opp_set_rate (struct device *dev,unsigned long freq) { - struct dev_pm_opp *opp __free(put_opp); + struct dev_pm_opp *opp __free(put_opp) = NULL; opp =devfreq_recommended_opp (dev, &freq,0 );if (IS_ERR (opp))
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The function iris_enable_power_domains leaks a runtime PM usage counter if pm_runtime_get_sync fails.
- [High] The function iris_disable_power_domains fails to release the runtime PM reference if iris_opp_set_rate fails. --
commit 52842abee5a5e7d3e9ab2afbbc3eabb0f32fde2e
Author: Hungyu Lin <[email protected]>
media: qcom: iris: initialize managed OPP pointer
Initialize the __free(put_opp) managed OPP pointer to NULL to ensure the cleanup handler always sees a defined value.
drivers/media/platform/qcom/iris/iris_resources.c int iris_unset_icc_bw(struct iris_core *core) · line 67
Quoted 13 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1@@ -61,7 +61,7 @@ int iris_unset_icc_bw(struct iris_core *core)int iris_opp_set_rate (struct device *dev,unsigned long freq) { - struct dev_pm_opp *opp __free(put_opp); + struct dev_pm_opp *opp __free(put_opp) = NULL; opp =devfreq_recommended_opp (dev, &freq,0 );if (IS_ERR (opp))
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this file, I noticed a pre-existing issue in iris_enable_power_domains():
drivers/media/platform/qcom/iris/iris_resources.c:iris_enable_power_domains() {
...
ret = pm_runtime_get_sync(pd_dev);
if (ret < 0)
return ret;
...
}Is the runtime PM usage counter leaked here? pm_runtime_get_sync() increments the counter even on failure. Should this use pm_runtime_resume_and_get() instead, or call pm_runtime_put_noidle() on the error path?
[Severity: High]
This is also a pre-existing issue, but I noticed a similar concern in iris_disable_power_domains() in the same file:
drivers/media/platform/qcom/iris/iris_resources.c:iris_disable_power_domains() {
...
ret = iris_opp_set_rate(core->dev, 0);
if (ret)
return ret;
pm_runtime_put_sync(pd_dev);
...
}Could returning early permanently leak the runtime PM reference if iris_opp_set_rate() fails? Should pm_runtime_put_sync() still be called during teardown even if setting the rate returns an error?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 15 lines · Hungyu Lin
Initialize the
__free(put_opp)managed OPP pointer to NULL.This ensures the cleanup handler always sees a defined value and avoids leaving the managed pointer uninitialized before assignment.
Signed-off-by Hungyu Lin <[email protected]>--- drivers/media/platform/qcom/iris/iris_resources.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/qcom/iris/iris_resources.c +0
-0
drivers/media/platform/qcom/iris/iris_resources.c int iris_unset_icc_bw(struct iris_core *core) · line 66
Quoted 7 lines
drivers/media/platform/qcom/iris/iris_resources.c +1
-1@@ -61,7 +61,7 @@ int iris_unset_icc_bw(struct iris_core *core)int iris_opp_set_rate (struct device *dev,unsigned long freq) { - struct dev_pm_opp *opp __free(put_opp); + struct dev_pm_opp *opp __free(put_opp) = NULL; opp =devfreq_recommended_opp (dev, &freq,0 );
No. Rather squash these two lines.
Quoted 4 lines
drivers/media/platform/qcom/iris/iris_resources.c +0
-0if (IS_ERR (opp))Signature · 1 line
2.34.1
Signature · 2 lines
With best wishes Dmitry
Bryan O'Donoghue
maintainerQuoted 24 lines · Hungyu Lin
Initialize the
__free(put_opp)managed OPP pointer to NULL.This ensures the cleanup handler always sees a defined value and avoids leaving the managed pointer uninitialized before assignment.
Signed-off-by Hungyu Lin <[email protected]>--- drivers/media/platform/qcom/iris/iris_resources.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/qcom/iris/iris_resources.c +1
-2@@ -61,7 +61,7 @@ int iris_unset_icc_bw(struct iris_core *core)int iris_opp_set_rate (struct device *dev,unsigned long freq) { - struct dev_pm_opp *opp __free(put_opp); + struct dev_pm_opp *opp __free(put_opp) = NULL; opp =devfreq_recommended_opp (dev, &freq,0 );if (IS_ERR (opp)) --
Quoted 3 lines
2.34.1
Requires a Fixes:
+ Cc: [email protected]
---
bod