* [PATCH] EDAC/device: Use flexible array for scrub data
@ 2026-07-29 1:06 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-07-29 1:06 UTC (permalink / raw)
To: linux-edac; +Cc: Borislav Petkov, Tony Luck, open list
Store EDAC scrub feature data in the device feature context
allocation instead of allocating it separately.
This ties the scrub data lifetime directly to the feature context, removes
a separate allocation failure path.
Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/edac/edac_device.c | 12 ++----------
include/linux/edac.h | 2 +-
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
index cf0d3c2dfc04..fd3e4631ce17 100644
--- a/drivers/edac/edac_device.c
+++ b/drivers/edac/edac_device.c
@@ -577,7 +577,6 @@ static void edac_dev_release(struct device *dev)
struct edac_dev_feat_ctx *ctx = container_of(dev, struct edac_dev_feat_ctx, dev);
kfree(ctx->mem_repair);
- kfree(ctx->scrub);
kfree(ctx->dev.groups);
kfree(ctx);
}
@@ -643,7 +642,7 @@ int edac_dev_register(struct device *parent, char *name,
}
}
- ctx = kzalloc_obj(*ctx);
+ ctx = kzalloc_flex(*ctx, scrub, scrub_cnt);
if (!ctx)
return -ENOMEM;
@@ -651,16 +650,10 @@ int edac_dev_register(struct device *parent, char *name,
if (!ras_attr_groups)
goto ctx_free;
- if (scrub_cnt) {
- ctx->scrub = kzalloc_objs(*ctx->scrub, scrub_cnt);
- if (!ctx->scrub)
- goto groups_free;
- }
-
if (mem_repair_cnt) {
ctx->mem_repair = kzalloc_objs(*ctx->mem_repair, mem_repair_cnt);
if (!ctx->mem_repair)
- goto data_mem_free;
+ goto groups_free;
}
attr_gcnt = 0;
@@ -748,7 +741,6 @@ int edac_dev_register(struct device *parent, char *name,
data_mem_free:
kfree(ctx->mem_repair);
- kfree(ctx->scrub);
groups_free:
kfree(ras_attr_groups);
ctx_free:
diff --git a/include/linux/edac.h b/include/linux/edac.h
index a6b47d27052a..3d8ee12c11be 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -864,9 +864,9 @@ struct edac_dev_data {
struct edac_dev_feat_ctx {
struct device dev;
void *private;
- struct edac_dev_data *scrub;
struct edac_dev_data ecs;
struct edac_dev_data *mem_repair;
+ struct edac_dev_data scrub[];
};
struct edac_dev_feature {
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-29 1:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-29 1:06 [PATCH] EDAC/device: Use flexible array for scrub data Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®