* [PATCHv2] EDAC/i7core: Use kzalloc_flex()
@ 2026-03-13 21:59 Rosen Penev
2026-03-13 22:19 ` Luck, Tony
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-03-13 21:59 UTC (permalink / raw)
To: linux-edac
Cc: Mauro Carvalho Chehab, Borislav Petkov, Tony Luck, Kees Cook,
Gustavo A. R. Silva, open list,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
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>
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
---
v2: change subject
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;
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2] EDAC/i7core: Use kzalloc_flex()
2026-03-13 21:59 [PATCHv2] EDAC/i7core: Use kzalloc_flex() Rosen Penev
@ 2026-03-13 22:19 ` Luck, Tony
0 siblings, 0 replies; 2+ messages in thread
From: Luck, Tony @ 2026-03-13 22:19 UTC (permalink / raw)
To: Rosen Penev
Cc: linux-edac, Mauro Carvalho Chehab, Borislav Petkov, Kees Cook,
Gustavo A. R. Silva, open list,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
On Fri, Mar 13, 2026 at 02:59:00PM -0700, Rosen Penev wrote:
> 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>
> Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Merged into RAS tree. Will go to Linus in v7.1 merge window.
Thanks
-Tony
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-13 22:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 21:59 [PATCHv2] EDAC/i7core: Use kzalloc_flex() Rosen Penev
2026-03-13 22:19 ` Luck, Tony
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox