]> git.baikalelectronics.ru Git - uboot.git/commitdiff
drivers: core: lists: fix for loop index type
authorAlexander Preißner <fpga-garage@preissner-muc.de>
Sat, 6 Nov 2021 01:08:59 +0000 (02:08 +0100)
committerSimon Glass <sjg@chromium.org>
Thu, 2 Dec 2021 16:15:43 +0000 (09:15 -0700)
* fixes the bug in function bind_drivers_pass that for
CONFIG_CC_OPTIMIZE_FOR_SIZE=n and no entries in the driver_info list,
i.e. n_ents == 0, the processor steps into the first loop iteration
despite the loop condition being false.
* the Xilinx Zynq-7000 device would eventually hang due to an attempted
access to an invalid memory address
* the bug is fixed by changing the type of idx from uint to int

Board: zynq-zybo
Target: ARM
Compiler: arm-none-eabi-gcc 9.2.1

Signed-off-by: Alexander Preissner <fpga-garage@preissner-muc.de>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
drivers/core/lists.c

index 5d4f2ea0e3ad055058b02d9317a529de4fd3ba99..d2e9dc5719be262b3bc0cfcbaec61fd2f1311640 100644 (file)
@@ -58,7 +58,7 @@ static int bind_drivers_pass(struct udevice *parent, bool pre_reloc_only)
        const int n_ents = ll_entry_count(struct driver_info, driver_info);
        bool missing_parent = false;
        int result = 0;
-       uint idx;
+       int idx;
 
        /*
         * Do one iteration through the driver_info records. For of-platdata,