fix dfu alt buffer clearing
Subsystems (2)
cover fix dfu alt buffer clearing
Hi,
This patch series applies the same fix in five different locations (the detailed description of the fix is in the patches).
I did validate statically by looking at the assembly before/after for all five cases, using the following defconfigs:
stm32mp15_defconfig
synquacer_developerbox_defconfig
xilinx_versal_virt_defconfig
xilinx_zynq_virt_defconfig
xilinx_zynqmp_kria_defconfig
Best regards,
Vincent.
Vincent Stehlé (5):
fwu: developerbox: fix dfu alt buffer clearing
board: st: common: fix dfu alt buffer clearing
arm64: versal: fix dfu alt buffer clearing
xilinx: zynq: fix dfu alt buffer clearing
arm64: zynqmp: fix dfu alt buffer clearing
board/socionext/developerbox/fwu_plat.c | 2 +- board/st/common/stm32mp_dfu.c | 2 +- board/xilinx/versal/board.c | 2 +- board/xilinx/zynq/board.c | 2 +- board/xilinx/zynqmp/zynqmp.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.47.2
PATCH 1/5 fwu: developerbox: fix dfu alt buffer clearing
The set_dfu_alt_info() function calls the ALLOC_CACHE_ALIGN_BUFFER() macro to declare a buf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expression sizeof(buf)'.
While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.
--- board/socionext/developerbox/fwu_plat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/socionext/developerbox/fwu_plat.c +1 -1
@@ -18,7 +18,7 @@ void set_dfu_alt_info(char *interface, char *devstr)struct mtd_info *mtd;int ret; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );mtd_probe_devices ();
Signature · 1 line
2.47.2
Re: [PATCH 1/5] fwu: developerbox: fix dfu alt buffer clearing
Hi Vincent,
Thank you for the patch.
Quoted 9 lines · Vincent Stehlé
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.
Quoted 5 lines
Fixes 6b403ca4dcf4 ("fwu: DeveloperBox: add support for FWU")Signed-off-by Vincent Stehlé <[email protected]>Cc Masahisa Kojima <[email protected]>Cc Tom Rini <[email protected]>Cc Jassi Brar <[email protected]>
Quoted 19 lines
--- board/socionext/developerbox/fwu_plat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/socionext/developerbox/fwu_plat.c +1
-1@@ -18,7 +18,7 @@ void set_dfu_alt_info(char *interface, char *devstr)struct mtd_info *mtd;int ret; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );mtd_probe_devices ();Signature · 1 line
2.47.2
PATCH 2/5 board: st: common: fix dfu alt buffer clearing
In reply to Vincent StehléThe set_dfu_alt_info() function calls the ALLOC_CACHE_ALIGN_BUFFER() macro to declare a buf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expression sizeof(buf)'.
While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.
--- board/st/common/stm32mp_dfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/st/common/stm32mp_dfu.c +1 -1
@@ -105,7 +105,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );snprintf (buf,DFU_ALT_BUF_LEN ,"ram 0=%s" ,CONFIG_DFU_ALT_RAM0 );
Signature · 1 line
2.47.2
Re: [PATCH 2/5] board: st: common: fix dfu alt buffer clearing
Hi Vincent,
Thank you for the patch.
Quoted 9 lines · Vincent Stehlé
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.
Quoted 6 lines
Fixes ec2933e543df ("board: stm32mp1: move set_dfu_alt_info in st common directory")Signed-off-by Vincent Stehlé <[email protected]>Cc Patrick Delaunay <[email protected]>Cc Patrice Chotard <[email protected]>Cc Tom Rini <[email protected]>Cc Marek Vasut <[email protected]>
Quoted 19 lines
--- board/st/common/stm32mp_dfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/st/common/stm32mp_dfu.c +1
-1@@ -105,7 +105,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );snprintf (buf,DFU_ALT_BUF_LEN ,"ram 0=%s" ,CONFIG_DFU_ALT_RAM0 );Signature · 1 line
2.47.2
Re: [PATCH 2/5] board: st: common: fix dfu alt buffer clearing
Quoted 15 lines · Mattijs Korpershoek
Hi Vincent,
Thank you for the patch.
Quoted 9 lines · Vincent Stehlé
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.
Quoted 8 lines
Quoted 6 lines
Fixes ec2933e543df ("board: stm32mp1: move set_dfu_alt_info in st common directory")Signed-off-by Vincent Stehlé <[email protected]>Cc Patrick Delaunay <[email protected]>Cc Patrice Chotard <[email protected]>Cc Tom Rini <[email protected]>Cc Marek Vasut <[email protected]>Reviewed-by Mattijs Korpershoek <[email protected]>
Patrice, Patrick,
This was assigned to me on patchwork. As [3-5] have been applied already by Michal, could you please pick this up?
I've assigned it to Patrice on patchwork.
Quoted 20 lines
Quoted 20 lines
--- board/st/common/stm32mp_dfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/st/common/stm32mp_dfu.c +1
-1@@ -105,7 +105,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );snprintf (buf,DFU_ALT_BUF_LEN ,"ram 0=%s" ,CONFIG_DFU_ALT_RAM0 );Signature · 1 line
2.47.2
Re: [PATCH 2/5] board: st: common: fix dfu alt buffer clearing
In reply to Vincent StehléQuoted 24 lines · Vincent Stehlé
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.Fixes ec2933e543df ("board: stm32mp1: move set_dfu_alt_info in st common directory")Signed-off-by Vincent Stehlé <[email protected]>Cc Patrick Delaunay <[email protected]>Cc Patrice Chotard <[email protected]>Cc Tom Rini <[email protected]>Cc Marek Vasut <[email protected]>--- board/st/common/stm32mp_dfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/st/common/stm32mp_dfu.c +0
-0
board/st/common/stm32mp_dfu.c void set_dfu_alt_info(char *interface, char *devstr) · line 111
Quoted 8 lines
board/st/common/stm32mp_dfu.c +1
-1@@ -105,7 +105,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );snprintf (buf,DFU_ALT_BUF_LEN ,"ram 0=%s" ,CONFIG_DFU_ALT_RAM0 );
Hi Vincent,
Thanks
Re: [PATCH 2/5] board: st: common: fix dfu alt buffer clearing
Quoted 33 lines · Patrice CHOTARD
Quoted 30 lines · Vincent Stehlé
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.Fixes ec2933e543df ("board: stm32mp1: move set_dfu_alt_info in st common directory")Signed-off-by Vincent Stehlé <[email protected]>Cc Patrick Delaunay <[email protected]>Cc Patrice Chotard <[email protected]>Cc Tom Rini <[email protected]>Cc Marek Vasut <[email protected]>--- board/st/common/stm32mp_dfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/st/common/stm32mp_dfu.c +1
-1@@ -105,7 +105,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );
Quoted 8 lines
board/st/common/stm32mp_dfu.c void set_dfu_alt_info(char *interface, char *devstr) · line 111
Quoted 2 lines
board/st/common/stm32mp_dfu.c +0
-0snprintf (buf,DFU_ALT_BUF_LEN ,"ram 0=%s" ,CONFIG_DFU_ALT_RAM0 );Hi Vincent,
Reviewed-by Patrice Chotard <[email protected]>Thanks
Applied to u-boot-stm32/master
Thanks
Patrice
PATCH 3/5 arm64: versal: fix dfu alt buffer clearing
In reply to Vincent StehléThe set_dfu_alt_info() function calls the ALLOC_CACHE_ALIGN_BUFFER() macro to declare a buf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expression sizeof(buf)'.
While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.
--- board/xilinx/versal/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/xilinx/versal/board.c +1 -1
@@ -396,7 +396,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN ); multiboot =env_get_hex ("multiboot" , multiboot);
Signature · 1 line
2.47.2
RE: [PATCH 3/5] arm64: versal: fix dfu alt buffer clearing
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 19 lines
From: U-Boot <[email protected]> On Behalf Of Vincent Stehlé
Sent: Monday, April 7, 2025 10:35 PM
To: [email protected]
Cc: Vincent Stehlé <[email protected]>; Jassi Brar <[email protected]>; Marek Vasut <[email protected]>; Masahisa Kojima <[email protected]>; Simek, Michal <[email protected]>; Patrice Chotard <[email protected]>; Patrick Delaunay <[email protected]>; Tom Rini <[email protected]>
Subject: [PATCH 3/5] arm64: versal: fix dfu alt buffer clearingCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.
Quoted 8 lines
While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.Fixes 064c8978b44f ("arm64: versal: Enable capsule update (SD)")Signed-off-by Vincent Stehlé <[email protected]>Cc Michal Simek <[email protected]>Cc Tom Rini <[email protected]>
Quoted 19 lines
--- board/xilinx/versal/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/xilinx/versal/board.c index renamed from board/xilinx/versal/board.c +0
-0
b4483d00ad1..3edccc979d8100644board/xilinx/versal/board.c +1
-2@@ -396,7 +396,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN ); multiboot =env_get_hex ("multiboot" , multiboot); --2.47.2
Re: [PATCH 3/5] arm64: versal: fix dfu alt buffer clearing
In reply to Vincent StehléQuoted 22 lines · Vincent Stehlé
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.Fixes 064c8978b44f ("arm64: versal: Enable capsule update (SD)")Signed-off-by Vincent Stehlé <[email protected]>Cc Michal Simek <[email protected]>Cc Tom Rini <[email protected]>--- board/xilinx/versal/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/xilinx/versal/board.c +0
-0
board/xilinx/versal/board.c void set_dfu_alt_info(char *interface, char *devstr) · line 402
Quoted 8 lines
board/xilinx/versal/board.c +1
-1@@ -396,7 +396,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN ); multiboot =env_get_hex ("multiboot" , multiboot);
Applied.
M
PATCH 4/5 xilinx: zynq: fix dfu alt buffer clearing
In reply to Vincent StehléThe set_dfu_alt_info() function calls the ALLOC_CACHE_ALIGN_BUFFER() macro to declare a buf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expression sizeof(buf)'.
While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.
--- board/xilinx/zynq/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/xilinx/zynq/board.c +1 -1
@@ -176,7 +176,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );switch ((zynq_slcr_get_boot_mode ()) &ZYNQ_BM_MASK ) {#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME )
Signature · 1 line
2.47.2
RE: [PATCH 4/5] xilinx: zynq: fix dfu alt buffer clearing
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 19 lines
From: U-Boot <[email protected]> On Behalf Of Vincent Stehlé
Sent: Monday, April 7, 2025 10:35 PM
To: [email protected]
Cc: Vincent Stehlé <[email protected]>; Jassi Brar <[email protected]>; Marek Vasut <[email protected]>; Masahisa Kojima <[email protected]>; Simek, Michal <[email protected]>; Patrice Chotard <[email protected]>; Patrick Delaunay <[email protected]>; Tom Rini <[email protected]>
Subject: [PATCH 4/5] xilinx: zynq: fix dfu alt buffer clearingCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.
Quoted 8 lines
While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.Fixes c67fecd2125b ("ARM: zynq: Enable capsule update for qspi and mmc")Signed-off-by Vincent Stehlé <[email protected]>Cc Michal Simek <[email protected]>Cc Tom Rini <[email protected]>
Quoted 19 lines
--- board/xilinx/zynq/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/xilinx/zynq/board.c index renamed from board/xilinx/zynq/board.c +0
-0
8dbfa560423..d8d4d5022ae100644board/xilinx/zynq/board.c +1
-2@@ -176,7 +176,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );switch ((zynq_slcr_get_boot_mode ()) &ZYNQ_BM_MASK ) {#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ) --2.47.2
Re: [PATCH 4/5] xilinx: zynq: fix dfu alt buffer clearing
In reply to Vincent StehléQuoted 22 lines · Vincent Stehlé
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.Fixes c67fecd2125b ("ARM: zynq: Enable capsule update for qspi and mmc")Signed-off-by Vincent Stehlé <[email protected]>Cc Michal Simek <[email protected]>Cc Tom Rini <[email protected]>--- board/xilinx/zynq/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/xilinx/zynq/board.c +0
-0
board/xilinx/zynq/board.c void set_dfu_alt_info(char *interface, char *devstr) · line 182
Quoted 8 lines
board/xilinx/zynq/board.c +1
-1@@ -176,7 +176,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN );switch ((zynq_slcr_get_boot_mode ()) &ZYNQ_BM_MASK ) {#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME )
Applied.
M
PATCH 5/5 arm64: zynqmp: fix dfu alt buffer clearing
In reply to Vincent StehléThe set_dfu_alt_info() function calls the ALLOC_CACHE_ALIGN_BUFFER() macro to declare a buf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expression sizeof(buf)'.
While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.
--- board/xilinx/zynqmp/zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/xilinx/zynqmp/zynqmp.c +1 -1
@@ -669,7 +669,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN ); multiboot =multi_boot ();if (multiboot <0 )
Signature · 1 line
2.47.2
RE: [PATCH 5/5] arm64: zynqmp: fix dfu alt buffer clearing
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 19 lines
From: U-Boot <[email protected]> On Behalf Of Vincent Stehlé
Sent: Monday, April 7, 2025 10:35 PM
To: [email protected]
Cc: Vincent Stehlé <[email protected]>; Jassi Brar <[email protected]>; Marek Vasut <[email protected]>; Masahisa Kojima <[email protected]>; Simek, Michal <[email protected]>; Patrice Chotard <[email protected]>; Patrick Delaunay <[email protected]>; Tom Rini <[email protected]>
Subject: [PATCH 5/5] arm64: zynqmp: fix dfu alt buffer clearingCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.
Quoted 8 lines
While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.Fixes b86f43de0be0 ("xilinx: zynqmp: Add support for runtime dfu_alt_info setup")Signed-off-by Vincent Stehlé <[email protected]>Cc Michal Simek <[email protected]>Cc Tom Rini <[email protected]>
Quoted 19 lines
--- board/xilinx/zynqmp/zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/xilinx/zynqmp/zynqmp.c index renamed from board/xilinx/zynqmp/zynqmp.c +0
-0
820fb252a3f..687dcd3ac9d100644board/xilinx/zynqmp/zynqmp.c +1
-2@@ -669,7 +669,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN ); multiboot =multi_boot ();if (multiboot <0 ) --2.47.2
Re: [PATCH 5/5] arm64: zynqmp: fix dfu alt buffer clearing
In reply to Vincent StehléQuoted 22 lines · Vincent Stehlé
The
set_dfu_alt_info()function calls theALLOC_CACHE_ALIGN_BUFFER()macro to declare abuf' variable pointer into an array allocated on the stack. It then calls the memset() function to clear the useable portion of the array using the idiomatic expressionsizeof(buf)'.While this would indeed work fine for an array, in the present case we end up clearing only the size of a pointer.
Fix this by specifying the explicit size `DFU_ALT_BUF_LEN' instead.Fixes b86f43de0be0 ("xilinx: zynqmp: Add support for runtime dfu_alt_info setup")Signed-off-by Vincent Stehlé <[email protected]>Cc Michal Simek <[email protected]>Cc Tom Rini <[email protected]>--- board/xilinx/zynqmp/zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)board/xilinx/zynqmp/zynqmp.c +0
-0
board/xilinx/zynqmp/zynqmp.c void set_dfu_alt_info(char *interface, char *devstr) · line 675
Quoted 8 lines
board/xilinx/zynqmp/zynqmp.c +1
-1@@ -669,7 +669,7 @@ void set_dfu_alt_info(char *interface, char *devstr)if (env_get ("dfu_alt_info" ))return ; -memset (buf,0 ,sizeof (buf)); +memset (buf,0 ,DFU_ALT_BUF_LEN ); multiboot =multi_boot ();if (multiboot <0 )
Applied.
M
Re: (subset) [PATCH 0/5] fix dfu alt buffer clearing
In reply to Vincent StehléHi,
Quoted 6 lines · Vincent Stehlé
This patch series applies the same fix in five different locations (the detailed description of the fix is in the patches).
I did validate statically by looking at the assembly before/after for all five cases, using the following defconfigs:
Quoted 7 lines
stm32mp15_defconfig
synquacer_developerbox_defconfig
xilinx_versal_virt_defconfig
xilinx_zynq_virt_defconfig
xilinx_zynqmp_kria_defconfig[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)
[1/5] fwu: developerbox: fix dfu alt buffer clearing
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/39a719dce59607d6abcac17cc2683aa9f2162539
--
Mattijs