[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d940183a-c00d-3a96-37bb-9553583f160a@embeddedor.com>
Date: Wed, 28 Aug 2019 14:36:59 -0500
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: "Verma, Vishal L" <vishal.l.verma@...el.com>,
"Williams, Dan J" <dan.j.williams@...el.com>,
"Jiang, Dave" <dave.jiang@...el.com>,
"Busch, Keith" <keith.busch@...el.com>,
"Weiny, Ira" <ira.weiny@...el.com>
Cc: "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()
Hi Vishal,
On 8/28/19 1:51 PM, Verma, Vishal L wrote:
[..]
>
> Hi Gustavo,
>
> The patch looks good to me, however it looks like it might've missed
> some instances where this replacement can be performed?
>
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;
};
> [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():
size_t flush_data_size = sizeof(void *);
[..]
for (i = 0; i < nd_region->ndr_mappings; i++) {
[..]
/* at least one null hint slot per-dimm for the "no-hint" case */
flush_data_size += sizeof(void *);
[..]
flush_data_size += nvdimm->num_flush * sizeof(void *);
}
Thanks
--
Gustavo
Powered by blists - more mailing lists