EDAC/i7core: Use kzalloc_flex()
Subsystems (2)
PATCH v2 1/1 EDAC/i7core: Use kzalloc_flex()
Simplifies allocations by using a flexible array member in this struct.
Add __counted_by to get extra runtime analysis. Move counting variable assignment to right after allocation as required by __counted_by.
Signed-off-by Rosen Penev <[email protected]>
Reviewed-by Qiuxu Zhuo <[email protected]>
---
v2: change subject
drivers/edac/i7core_edac.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/edac/i7core_edac.c +4 -11
@@ -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;list_add_tail (&i7core_dev->list, &i7core_edac_list);return i7core_dev;
@@ -475,7 +469,6 @@ static struct i7core_dev *alloc_i7core_dev(u8 socket,static void free_i7core_dev (struct i7core_dev *i7core_dev) {list_del (&i7core_dev->list); -kfree (i7core_dev->pdev);kfree (i7core_dev); }
--
2.53.0
Quoted 7 lines · Rosen Penev
Simplifies allocations by using a flexible array member in this struct.
Add
__counted_byto get extra runtime analysis. Move counting variable assignment to right after allocation as required by__counted_by.Signed-off-by Rosen Penev <[email protected]>Reviewed-by Qiuxu Zhuo <[email protected]>
Merged into RAS tree. Will go to Linus in v7.1 merge window.
Thanks
-Tony