[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPcyv4jEgk3Nsax0_KxDEsOPY91_py5NTyh2F58zVcoxaO0_Tw@mail.gmail.com>
Date: Thu, 29 Aug 2019 14:04:49 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: "Verma, Vishal L" <vishal.l.verma@...el.com>
Cc: "Jiang, Dave" <dave.jiang@...el.com>,
"gustavo@...eddedor.com" <gustavo@...eddedor.com>,
"Busch, Keith" <keith.busch@...el.com>,
"Weiny, Ira" <ira.weiny@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-nvdimm@...ts.01.org" <linux-nvdimm@...ts.01.org>
Subject: Re: [PATCH] libnvdimm, region: Use struct_size() in kzalloc()
On Wed, Aug 28, 2019 at 1:24 PM Verma, Vishal L
<vishal.l.verma@...el.com> wrote:
>
> 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@...el.com>
Thanks, applied.
Powered by blists - more mailing lists