diff mbox series

cxl: Add warning comment to cxl_root_decoder

Message ID 168255005846.53394.2779436232786699829.stgit@djiang5-mobl3
State New, archived
Headers show
Series cxl: Add warning comment to cxl_root_decoder | expand

Commit Message

Dave Jiang April 26, 2023, 11 p.m. UTC
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'.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/cxl/cxl.h |    1 +
 1 file changed, 1 insertion(+)

Comments

Alison Schofield April 27, 2023, 4:03 a.m. UTC | #1
On Wed, Apr 26, 2023 at 04:00:58PM -0700, Dave Jiang wrote:

Perhaps more content in the commit message, like:
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'.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/cxl/cxl.h |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index 044a92d9813e..999c0aa5ed54 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -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 */

Can this comment fit within 80 chars?

>  	struct cxl_switch_decoder cxlsd;
>  };
>  
> 
>
diff mbox series

Patch

diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
index 044a92d9813e..999c0aa5ed54 100644
--- a/drivers/cxl/cxl.h
+++ b/drivers/cxl/cxl.h
@@ -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;
 };