Skip to contentSkip to conversation

cxl: Warn of flexible array in struct cxl_root_decoder

PATCH Superseded Dave Jiang 1 participant 2 messages Apr 27, 2023 CXL

lore
Share & tools
lore

Dave Jiang

author maintainer
#0 lore raw

PATCH v2 1/1 cxl: Warn of flexible array in struct cxl_root_decoder

The 'cxl_switch_decoder' member in 'cxl_root_decoder' must be the last element due to 'cxl_switch_decoder' has a flexible array at the end of the struct. Any variables placed after will be corrupted. Add a warning comment to 'cxl_root_decoder'.

---
v2:
- Clarify subject (Alison)
- Fit comment under 80 chars. (Alison)

---
 drivers/cxl/cxl.h |    1 +
 1 file changed, 1 insertion(+)
drivers/cxl/cxl.h +1 -0
index 044a92d9813e..999c0aa5ed54 100644
@@ -419,6 +419,7 @@ struct cxl_root_decoder {
 	cxl_calc_hb_fn calc_hb;
 	void *platform_data;
 	struct mutex range_lock;
+	/* This must be the last member of the struct. It contains a flexible array */
 	struct cxl_switch_decoder cxlsd;
 };
 
author maintainer
#1 lore raw
Quoted 6 lines · Dave Jiang

The 'cxl_switch_decoder' member in 'cxl_root_decoder' must be the last element due to 'cxl_switch_decoder' has a flexible array at the end of the struct. Any variables placed after will be corrupted. Add a warning comment to 'cxl_root_decoder'.

Please disregard this version. Diff wasn't updated.

Quoted 23 lines

---
v2:
- Clarify subject (Alison)
- Fit comment under 80 chars. (Alison)

---
  drivers/cxl/cxl.h |    1 +
  1 file changed, 1 insertion(+)
drivers/cxl/cxl.h +1 -0
index 044a92d9813e..999c0aa5ed54 100644
@@ -419,6 +419,7 @@ struct cxl_root_decoder {
  	cxl_calc_hb_fn calc_hb;
  	void *platform_data;
  	struct mutex range_lock;
+	/* This must be the last member of the struct. It contains a flexible array */
  	struct cxl_switch_decoder cxlsd;
  };