[PATCH 4/4] handoff-data: add protection against multiple invocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux