drm/bridge: microchip-lvds: Fix runtime PM leak in mchp_lvds_enable()
Subsystems (5)
PATCH 1/1 drm/bridge: microchip-lvds: Fix runtime PM leak in mchp_lvds_enable()
mchp_lvds_enable() resumes the device with pm_runtime_get_sync() and returns early when the resume fails. pm_runtime_get_sync() increments the runtime PM usage count even when it fails, so returning without dropping the reference leaks it and prevents the device from ever suspending again once the error has been hit.
Drop the runtime PM reference with pm_runtime_put_noidle() on the resume failure path before returning.
--- drivers/gpu/drm/bridge/microchip-lvds.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/microchip-lvds.c +1 -0
@@ -127,6 +127,7 @@ static void mchp_lvds_enable(struct drm_bridge *bridge) ret =pm_runtime_get_sync (lvds->dev);if (ret <0 ) {dev_err (lvds->dev,"failed to get pm runtime: %d\n" , ret); +pm_runtime_put_noidle (lvds->dev);return ; }
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] drm/bridge: runtime PM usage counter underflow on atomic_enable error --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/bridge: runtime PM usage counter underflow on atomic_enable error --
commit f6da183dff281321349d56635d572cdbbecf6393
Author: Wentao Liang <[email protected]>
drm/bridge: microchip-lvds: Fix runtime PM leak in mchp_lvds_enable()
This patch attempts to fix a runtime PM usage counter leak in mchp_lvds_atomic_enable() by dropping the reference when pm_runtime_get_sync() fails.
drivers/gpu/drm/bridge/microchip-lvds.c static void mchp_lvds_atomic_enable(struct drm_bridge *bridge, · line 147
Quoted 9 lines
drivers/gpu/drm/bridge/microchip-lvds.c +1
-0@@ -144,6 +144,7 @@ static void mchp_lvds_atomic_enable(struct drm_bridge *bridge, ret =pm_runtime_get_sync (lvds->dev);if (ret <0 ) {dev_err (lvds->dev,"failed to get pm runtime: %d\n" , ret); +pm_runtime_put_noidle (lvds->dev);
[Severity: Medium]
Will this lead to a runtime PM usage counter underflow when the bridge is disabled?
The DRM bridge API's atomic_enable callback returns void, so the DRM core cannot be notified of a failure. If pm_runtime_get_sync() fails, the DRM core still considers the bridge enabled and will unconditionally call mchp_lvds_atomic_disable() during the next modeset or pipeline teardown.
Since this patch locally drops the PM reference here on the error path, the unconditional pm_runtime_put() in mchp_lvds_atomic_disable() will decrement the usage count a second time, causing an underflow. Before this patch, the reference left by the failing get_sync() balanced the unconditional put in the disable path.
Quoted 2 lines
drivers/gpu/drm/bridge/microchip-lvds.c +0
-0return ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
maintainerHi Wentao Liang,
Thanks for the patch, and Sashiko's automated review is correct here — this needs rework.
pm_runtime_get_sync() bumps the usage count even on failure, so today that leaked reference is consumed by the put in _disable().Adding pm_runtime_put_noidle() on the error path makes the later unconditional pm_runtime_put() underflow the counter.
Also, as of v7.2 the function is mchp_lvds_atomic_enable(), so please rebase it on to the latest and update the subject/commit message.
Quoted 33 lines · Wentao Liang
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
mchp_lvds_enable()resumes the device withpm_runtime_get_sync()and returns early when the resume fails.pm_runtime_get_sync()increments the runtime PM usage count even when it fails, so returning without dropping the reference leaks it and prevents the device from ever suspending again once the error has been hit.Drop the runtime PM reference with
pm_runtime_put_noidle()on the resume failure path before returning.Fixes 179b0769fc5f ("drm/bridge: add lvds controller support for sam9x7")Signed-off-by Wentao Liang <[email protected]>--- drivers/gpu/drm/bridge/microchip-lvds.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/bridge/microchip-lvds.c +1
-1@@ -127,6 +127,7 @@ static void mchp_lvds_enable(struct drm_bridge *bridge) ret =pm_runtime_get_sync (lvds->dev);if (ret <0 ) {dev_err (lvds->dev,"failed to get pm runtime: %d\n" , ret); +pm_runtime_put_noidle (lvds->dev);return ; } --2.34.1
Signature · 2 lines
Thanks and Regards, Manikandan M.