EDAC/sb: Use kzalloc_flex()
Subsystems (2)
PATCH v2 1/1 EDAC/sb: 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 immediately 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/sb_edac.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/edac/sb_edac.c +3 -11
@@ -364,11 +364,11 @@ struct sbridge_dev {int seg;u8 bus, mc;u8 node_id, source_id; -struct pci_dev **pdev;enum domain dom;int n_devs;int i_devs;struct mem_ctl_info *mci; + struct pci_dev *pdev[] __counted_by(n_devs); };struct knl_pvt {
@@ -771,21 +771,14 @@ static struct sbridge_dev *alloc_sbridge_dev(int seg, u8 bus, enum domain dom, {struct sbridge_dev *sbridge_dev; - sbridge_dev =kzalloc_obj (*sbridge_dev); + sbridge_dev =kzalloc_flex (*sbridge_dev, pdev, table->n_devs_per_imc);if (!sbridge_dev)return NULL ; - sbridge_dev->pdev =kzalloc_objs (*sbridge_dev->pdev, - table->n_devs_per_imc); -if (!sbridge_dev->pdev) { -kfree (sbridge_dev); -return NULL ; - } - + sbridge_dev->n_devs = table->n_devs_per_imc; sbridge_dev->seg = seg; sbridge_dev->bus = bus; sbridge_dev->dom = dom; - sbridge_dev->n_devs = table->n_devs_per_imc;list_add_tail (&sbridge_dev->list, &sbridge_edac_list);return sbridge_dev;
@@ -794,7 +787,6 @@ static struct sbridge_dev *alloc_sbridge_dev(int seg, u8 bus, enum domain dom,static void free_sbridge_dev (struct sbridge_dev *sbridge_dev) {list_del (&sbridge_dev->list); -kfree (sbridge_dev->pdev);kfree (sbridge_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 immediately 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 7.1 merge window.
Thanks
-Tony