]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Fix iteration over driver_info records
authorPaul Barker <paul.barker@sancloud.com>
Mon, 14 Nov 2022 12:42:35 +0000 (12:42 +0000)
committerTom Rini <trini@konsulko.com>
Fri, 2 Dec 2022 13:39:00 +0000 (08:39 -0500)
We should only perform additional iteration steps when needed to
initialize the parent of a device. Other binding errors (such as a
missing driver) should not lead to additional iteration steps.

Unnecessary iteration steps can cause issues when memory is tightly
constrained (such as in the TPL/SPL) since device_bind_by_name()
unconditionally allocates memory for a struct udevice. On the SanCloud
BBE this led to boot failure caused by memory exhaustion in the SPL
when booting from SPI flash.

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
drivers/core/lists.c

index 3878957c9ef4bbdb02c3d2ad4c75f24eb31a9486..8034a8f48d99bca46e4df87a15215aa371b6297d 100644 (file)
@@ -120,10 +120,10 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only)
                int ret;
 
                ret = bind_drivers_pass(parent, pre_reloc_only);
-               if (!ret)
-                       break;
-               if (ret != -EAGAIN && !result)
+               if (!result || result == -EAGAIN)
                        result = ret;
+               if (ret != -EAGAIN)
+                       break;
        }
 
        return result;