Message ID | 168261044311.369593.10950998135160952191.stgit@djiang5-mobl3 |
---|---|
State | New, archived |
Headers | show |
Series | [RESEND,v2] cxl: Warn of flexible array in struct cxl_root_decoder | expand |
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; > }; > > >
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; > }; > > >
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; > }; > > >
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; };
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(+)