[PATCH v1 8/8] bootcount: gate bootcount_{inc, error}() behind !CONFIG_DM_BOOTCOUNT_GPT

dmukhin at ford.com dmukhin at ford.com
Fri Jun 5 05:39:07 CEST 2026


From: Denis Mukhin <dmukhin at ford.com> 

Autoboot calls into bootcount_inc()/bootcount_error() which rely on
environment variable.

Specifically, it may corrupt the state of a GPT-backed counter.

Gate bootcount_inc()/bootcount_error() by !CONFIG_DM_BOOTCOUNT_GPT to
compile out bootcount_store() calls on autoboot path.

Signed-off-by: Denis Mukhin <dmukhin at ford.com>
---
 include/bootcount.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/bootcount.h b/include/bootcount.h
index 86474569d365..8aae3cb7ff1b 100644
--- a/include/bootcount.h
+++ b/include/bootcount.h
@@ -74,7 +74,8 @@ void bootcount_store(ulong);
  */
 ulong bootcount_load(void);
 
-#if defined(CONFIG_SPL_BOOTCOUNT_LIMIT) || defined(CONFIG_TPL_BOOTCOUNT_LIMIT) || defined(CONFIG_BOOTCOUNT_LIMIT)
+#if (defined(CONFIG_SPL_BOOTCOUNT_LIMIT) || defined(CONFIG_TPL_BOOTCOUNT_LIMIT) || defined(CONFIG_BOOTCOUNT_LIMIT)) && \
+	!defined(CONFIG_DM_BOOTCOUNT_GPT)
 
 #ifdef CONFIG_SYS_BOOTCOUNT_LE
 static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
-- 
2.54.0



More information about the U-Boot mailing list