]> git.baikalelectronics.ru Git - uboot.git/commitdiff
power-domain: Fix use of uninitialized value in dev_power_domain_ctrl
authorSean Anderson <seanga2@gmail.com>
Wed, 23 Mar 2022 18:26:09 +0000 (14:26 -0400)
committerJaehoon Chung <jh80.chung@samsung.com>
Fri, 22 Apr 2022 12:19:21 +0000 (21:19 +0900)
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: efbabe6645 ("power-domain: fix hang in endless loop on i.MX8")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/power/domain/power-domain-uclass.c

index 33f9206bd09db5f93a516e03ddc0c1168265e2c9..1a317a00aa104aa7b02f54388f8981ce92bc42b0 100644 (file)
@@ -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;