From ccd063e9812a2bdcbeafbbcd8dcb062bfc290f24 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Wed, 3 Apr 2019 09:12:48 +0200 Subject: watchdog: Move watchdog_dev to data section (BSS may not be cleared) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch moves all instances of static "watchdog_dev" declarations to the "data" section. This may be needed, as the BSS may not be cleared in the early U-Boot phase, where watchdog_reset() is already beeing called. This may result in incorrect pointer access, as the check to "!watchdog_dev" in watchdog_reset() may not be true and the function may continue to run. Signed-off-by: Stefan Roese Cc: Heiko Schocher Cc: Tom Rini Cc: Michal Simek Cc: "Marek BehĂșn" Cc: Daniel Schwierzeck Tested-by: Michal Simek (on zcu100) Reviewed-by: Michal Simek --- board/xilinx/microblaze-generic/microblaze-generic.c | 2 +- board/xilinx/zynq/board.c | 7 +------ board/xilinx/zynqmp/zynqmp.c | 7 +------ 3 files changed, 3 insertions(+), 13 deletions(-) (limited to 'board/xilinx') diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c index c946ec3..28c9efa 100644 --- a/board/xilinx/microblaze-generic/microblaze-generic.c +++ b/board/xilinx/microblaze-generic/microblaze-generic.c @@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR; #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL; #endif /* !CONFIG_SPL_BUILD && CONFIG_WDT */ ulong ram_base; diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index b4b84df..ea26aad 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -19,17 +19,12 @@ DECLARE_GLOBAL_DATA_PTR; #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL; #endif #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_BOARD_EARLY_INIT_F) int board_early_init_f(void) { -# if defined(CONFIG_WDT) - /* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev = NULL; -# endif - return 0; } #endif diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 5e1d211..db27247 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR; #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT) -static struct udevice *watchdog_dev; +static struct udevice *watchdog_dev __attribute__((section(".data"))) = NULL; #endif #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ @@ -322,11 +322,6 @@ int board_early_init_f(void) ret = psu_init(); #endif -#if defined(CONFIG_WDT) && !defined(CONFIG_SPL_BUILD) - /* bss is not cleared at time when watchdog_reset() is called */ - watchdog_dev = NULL; -#endif - return ret; } -- cgit v1.1