> From: Rosen Penev <[email protected]>
> [...]
> Subject: [PATCH] EDAC, i7core: use kzalloc_flex
>
Could you use this style of subject? Thx.
EDAC/i7core: Use kzalloc_flex()
> Simplifies allocations by using a flexible array member in this struct.
>
> Add __counted_by to get extra runtime analysis.
>
> Signed-off-by: Rosen Penev <[email protected]>
> ---
> drivers/edac/i7core_edac.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c index
> 0f783173d0ec..b87c4c6471ea 100644
> --- a/drivers/edac/i7core_edac.c
> +++ b/drivers/edac/i7core_edac.c
> @@ -240,9 +240,9 @@ struct pci_id_table { struct i7core_dev {
> struct list_head list;
> u8 socket;
> - struct pci_dev **pdev;
> - int n_devs;
> struct mem_ctl_info *mci;
> + int n_devs;
> + struct pci_dev *pdev[] __counted_by(n_devs);
> };
>
> struct i7core_pvt {
> @@ -455,18 +455,12 @@ static struct i7core_dev *alloc_i7core_dev(u8
> socket, {
> struct i7core_dev *i7core_dev;
>
> - i7core_dev = kzalloc_obj(*i7core_dev);
> + i7core_dev = kzalloc_flex(*i7core_dev, pdev, table->n_devs);
> if (!i7core_dev)
> return NULL;
>
> - i7core_dev->pdev = kzalloc_objs(*i7core_dev->pdev, table->n_devs);
> - if (!i7core_dev->pdev) {
> - kfree(i7core_dev);
> - return NULL;
> - }
> -
> - i7core_dev->socket = socket;
> i7core_dev->n_devs = table->n_devs;
> + i7core_dev->socket = socket;
What's the reason for moving this line of code down here?
Other than the comments above:
Reviewed-by: Qiuxu Zhuo <[email protected]>