[PATCH] EDAC/device: Use flexible array for scrub data
Rosen Penev <[email protected]> Tue, 28 Jul 2026 18:06:13 -0700
| Newsgroups | org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- 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