mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
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 <rosenp@gmail.com> Signed-off-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Link: https://patch.msgid.link/20260313215900.6724-1-rosenp@gmail.com
This commit is contained in:
parent
62a9fc50e8
commit
7cbea96f66
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user