power-domain: Fix use of uninitialized value in dev_power_domain_ctrl
PATCH 1/1 power-domain: Fix use of uninitialized value in dev_power_domain_ctrl
If dev_count_phandle_with_args returns 0 or another error, then pd will never have been initialized by power_domain_get_by_index. Avoid comparing against pd.dev in this situation.
Fixes 3e4fcfa4bc ("power-domain: fix hang in endless loop on i.MX8")
Signed-off-by Sean Anderson <[email protected]>
---
drivers/power/domain/power-domain-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/domain/power-domain-uclass.c +1 -1
@@ -137,7 +137,7 @@ static int dev_power_domain_ctrl(struct udevice *dev, bool on)* off their power-domain parent. So we will get here again and * again and will be stuck in an endless loop. */ -if (!on &&dev_get_parent (dev) == pd.dev && +if (count >0 && !on &&dev_get_parent (dev) == pd.dev &&device_get_uclass_id (dev) ==UCLASS_POWER_DOMAIN )return ret;
Signature · 1 line
2.35.1
Quoted 11 lines · Sean Anderson
If
dev_count_phandle_with_argsreturns 0 or another error, then pd will never have been initialized bypower_domain_get_by_index. Avoid comparing against pd.dev in this situation.Fixes 3e4fcfa4bc ("power-domain: fix hang in endless loop on i.MX8")Signed-off-by Sean Anderson <[email protected]>---
drivers/power/domain/power-domain-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by Simon Glass <[email protected]>
Quoted 6 lines · Sean Anderson
If
dev_count_phandle_with_argsreturns 0 or another error, then pd will never have been initialized bypower_domain_get_by_index. Avoid comparing against pd.dev in this situation.Fixes 3e4fcfa4bc ("power-domain: fix hang in endless loop on i.MX8")Signed-off-by Sean Anderson <[email protected]>
Reviewed-by Jaehoon Chung <[email protected]>
Best Regards,
Jaehoon Chung
Quoted 18 lines
---
drivers/power/domain/power-domain-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/power/domain/power-domain-uclass.c +1
-1@@ -137,7 +137,7 @@ static int dev_power_domain_ctrl(struct udevice *dev, bool on)* off their power-domain parent. So we will get here again and * again and will be stuck in an endless loop. */ -if (!on &&dev_get_parent (dev) == pd.dev && +if (count >0 && !on &&dev_get_parent (dev) == pd.dev &&device_get_uclass_id (dev) ==UCLASS_POWER_DOMAIN )return ret;