Linux CXL
 help / color / mirror / Atom feed
* [RESEND PATCH v2] cxl: Warn of flexible array in struct cxl_root_decoder
@ 2023-04-27 15:47 Dave Jiang
  2023-04-27 17:29 ` Ira Weiny
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dave Jiang @ 2023-04-27 15:47 UTC (permalink / raw)
  To: linux-cxl; +Cc: dan.j.williams, vishal.l.verma, alison.schofield, ira.weiny

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>

---
v2:
- Clarify subject (Alison)
- Fit comment under 80 chars. (Alison)
---
 drivers/cxl/cxl.h |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
index 044a92d9813e..7db7e217b6f3 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;
+	/* Must be the last member. Struct contains a flexible array */
 	struct cxl_switch_decoder cxlsd;
 };
 



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH v2] cxl: Warn of flexible array in struct cxl_root_decoder
  2023-04-27 15:47 [RESEND PATCH v2] cxl: Warn of flexible array in struct cxl_root_decoder Dave Jiang
@ 2023-04-27 17:29 ` Ira Weiny
  2023-04-27 19:02 ` Alison Schofield
  2023-05-11 16:36 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Ira Weiny @ 2023-04-27 17:29 UTC (permalink / raw)
  To: Dave Jiang, linux-cxl
  Cc: dan.j.williams, vishal.l.verma, alison.schofield, ira.weiny

Dave Jiang wrote:
> 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>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> 
> ---
> v2:
> - Clarify subject (Alison)
> - Fit comment under 80 chars. (Alison)
> ---
>  drivers/cxl/cxl.h |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index 044a92d9813e..7db7e217b6f3 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;
> +	/* Must be the last member. Struct contains a flexible array */
>  	struct cxl_switch_decoder cxlsd;
>  };
>  
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH v2] cxl: Warn of flexible array in struct cxl_root_decoder
  2023-04-27 15:47 [RESEND PATCH v2] cxl: Warn of flexible array in struct cxl_root_decoder Dave Jiang
  2023-04-27 17:29 ` Ira Weiny
@ 2023-04-27 19:02 ` Alison Schofield
  2023-05-11 16:36 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Alison Schofield @ 2023-04-27 19:02 UTC (permalink / raw)
  To: Dave Jiang; +Cc: linux-cxl, dan.j.williams, vishal.l.verma, ira.weiny

On Thu, Apr 27, 2023 at 08:47:23AM -0700, Dave Jiang wrote:
> 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>
> 
> ---
> v2:
> - Clarify subject (Alison)
> - Fit comment under 80 chars. (Alison)

Thanks Dave,

Reviewed-by: Alison Schofield <alison.schofield@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..7db7e217b6f3 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;
> +	/* Must be the last member. Struct contains a flexible array */
>  	struct cxl_switch_decoder cxlsd;
>  };
>  
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH v2] cxl: Warn of flexible array in struct cxl_root_decoder
  2023-04-27 15:47 [RESEND PATCH v2] cxl: Warn of flexible array in struct cxl_root_decoder Dave Jiang
  2023-04-27 17:29 ` Ira Weiny
  2023-04-27 19:02 ` Alison Schofield
@ 2023-05-11 16:36 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2023-05-11 16:36 UTC (permalink / raw)
  To: Dave Jiang
  Cc: linux-cxl, dan.j.williams, vishal.l.verma, alison.schofield,
	ira.weiny

On Thu, 27 Apr 2023 08:47:23 -0700
Dave Jiang <dave.jiang@intel.com> wrote:

> 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>
Ugly requirement, so comment good to have.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> 
> ---
> v2:
> - Clarify subject (Alison)
> - Fit comment under 80 chars. (Alison)
> ---
>  drivers/cxl/cxl.h |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index 044a92d9813e..7db7e217b6f3 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;
> +	/* Must be the last member. Struct contains a flexible array */
>  	struct cxl_switch_decoder cxlsd;
>  };
>  
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-11 16:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-27 15:47 [RESEND PATCH v2] cxl: Warn of flexible array in struct cxl_root_decoder Dave Jiang
2023-04-27 17:29 ` Ira Weiny
2023-04-27 19:02 ` Alison Schofield
2023-05-11 16:36 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox