[PATCH 4/4] handoff-data: add protection against multiple invocation
Sascha Hauer
s.hauer at pengutronix.de
Wed Oct 30 04:30:39 PDT 2024
handoff_data_add_flags() passes statically allocated structs as handoff
data, thus we cannot allow it to be called multiple times as that would
reuse the same data. Add a BUG_ON() to catch this.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
include/pbl/handoff-data.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/pbl/handoff-data.h b/include/pbl/handoff-data.h
index eac3b9bf3e..bc1d403380 100644
--- a/include/pbl/handoff-data.h
+++ b/include/pbl/handoff-data.h
@@ -28,6 +28,10 @@ struct handoff_data_entry {
#define handoff_data_add_flags(_cookie, _data, _size, _flags) \
do { \
static struct handoff_data_entry hde __section(.data); \
+ \
+ /* using static data, do not invoke multiple times */ \
+ BUG_ON(hde.cookie); \
+ \
hde.cookie = _cookie; \
hde.data = _data; \
hde.size = _size; \
--
2.39.5
More information about the barebox
mailing list