On Wed, 31 Dec 2025 at 12:52, Yang Xiwen via B4 Relay
<[email protected]> wrote:
>
> From: Yang Xiwen <[email protected]>
>
> The current logic does not update the new parent in device_reparent() if
> old parent is NULL. The behavior is not desired. Fix it by setting the
> parent in this case.
>
> Fixes: cfecbaf4e768 ("dm: core: add support for device re-parenting")
> Signed-off-by: Yang Xiwen <[email protected]>
> ---
>  drivers/core/device.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <[email protected]>


>
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index 779f371b9d5b..497c32befde7 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -285,6 +285,11 @@ int device_reparent(struct udevice *dev, struct udevice 
> *new_parent)
>         assert(dev);
>         assert(new_parent);
>
> +       if (!dev->parent) {
> +               dev->parent = new_parent;
> +               return 0;
> +       }
> +
>         device_foreach_child_safe(pos, n, dev->parent) {
>                 if (pos->driver != dev->driver)
>                         continue;
>
> --
> 2.43.0
>
>

Reply via email to