lkml.org 
[lkml]   [2019]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] libnvdimm, region: Use struct_size() in kzalloc()
Date
On Wed, 2019-08-28 at 14:36 -0500, Gustavo A. R. Silva wrote:

> struct_size() does not apply to those scenarios. See below...
>
> > [1]:
> > https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/tree/drivers/nvdimm/region_devs.c#n1030
>
> struct_size() only applies to structures of the following kind:
>
> struct foo {
> int stuff;
> struct boo entry[];
> };
>
> and this scenario includes two different structures:
>
> struct nd_region {
> ...
> struct nd_mapping mapping[0];
> };
>
> struct nd_blk_region {
> ...
> struct nd_region nd_region;
> };

Yep - I neglected to actually look at the structures involved - you're
right, it doesn't apply here.

>
> > [2]:
> > https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/tree/drivers/nvdimm/region_devs.c#n96
> >
>
> In this scenario struct_size() does not apply directly because of the
> following
> logic before the call to devm_kzalloc():

Agreed, I missed that the calculation was more involved here.

Thanks for the clarifications, you can add:
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

\
 
 \ /
  Last update: 2019-08-28 22:25    [W:0.061 / U:0.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site