u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: core: lists: fix for loop index type
@ 2021-11-06  1:08 fpga-garage
  2021-12-02 16:12 ` Simon Glass
  2021-12-02 21:18 ` Simon Glass
  0 siblings, 2 replies; 3+ messages in thread
From: fpga-garage @ 2021-11-06  1:08 UTC (permalink / raw)
  To: u-boot; +Cc: Alexander Preissner

From: Alexander Preißner <fpga-garage@preissner-muc.de>

* 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>
---
 drivers/core/lists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 5d4f2ea0e3..d2e9dc5719 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -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,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers: core: lists: fix for loop index type
  2021-11-06  1:08 [PATCH] drivers: core: lists: fix for loop index type fpga-garage
@ 2021-12-02 16:12 ` Simon Glass
  2021-12-02 21:18 ` Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-12-02 16:12 UTC (permalink / raw)
  To: fpga-garage; +Cc: u-boot

On Sat, 6 Nov 2021 at 09:11, <fpga-garage@preissner-muc.de> wrote:
>
> From: Alexander Preißner <fpga-garage@preissner-muc.de>
>
> * 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>
> ---
>  drivers/core/lists.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/core/lists.c b/drivers/core/lists.c
> index 5d4f2ea0e3..d2e9dc5719 100644
> --- a/drivers/core/lists.c
> +++ b/drivers/core/lists.c
> @@ -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,
> --
> 2.25.1
>

Acked-by: Simon Glass <sjg@chromium.org>
Tested on sandbox:
Tested-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers: core: lists: fix for loop index type
  2021-11-06  1:08 [PATCH] drivers: core: lists: fix for loop index type fpga-garage
  2021-12-02 16:12 ` Simon Glass
@ 2021-12-02 21:18 ` Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-12-02 21:18 UTC (permalink / raw)
  To: Simon Glass; +Cc: u-boot, Alexander Preissner

On Sat, 6 Nov 2021 at 09:11, <fpga-garage@preissner-muc.de> wrote:
>
> From: Alexander Preißner <fpga-garage@preissner-muc.de>
>
> * 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>
> ---
>  drivers/core/lists.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
Applied to u-boot-dm/next, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-02 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-06  1:08 [PATCH] drivers: core: lists: fix for loop index type fpga-garage
2021-12-02 16:12 ` Simon Glass
2021-12-02 21:18 ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).