* [PATCH v2] drm/exynos: fimc: allocate formats as a flexible array member
@ 2026-11-11 22:01 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-11-11 22:01 UTC (permalink / raw)
To: Inki Dae, Seung-Woo Kim, Kyungmin Park, David Airlie,
Simona Vetter, Krzysztof Kozlowski, Peter Griffin, Kees Cook
Cc: Alim Akhtar, Gustavo A. R. Silva, dri-devel, linux-arm-kernel,
linux-samsung-soc, linux-kernel, linux-hardening
The formats array is allocated separately with devm_kcalloc() and only
referenced through the fimc_context. Make it a flexible array member at
the end of the context and allocate both in one go.
Annotate it with __counted_by(num_formats) so the array accesses can be
bounds checked with FORTIFY_SOURCE and UBSAN_BOUNDS.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
v2: use devm_kzalloc_flex().
drivers/gpu/drm/exynos/exynos_drm_fimc.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index 9c2ad95799ee..9233cd3b2f04 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -99,7 +99,6 @@ struct fimc_context {
void *dma_priv;
struct device *dev;
struct exynos_drm_ipp_task *task;
- struct exynos_drm_ipp_formats *formats;
unsigned int num_formats;
void __iomem *regs;
@@ -108,6 +107,7 @@ struct fimc_context {
struct fimc_scaler sc;
int id;
int irq;
+ struct exynos_drm_ipp_formats formats[] __counted_by(num_formats);
};
static u32 fimc_read(struct fimc_context *ctx, u32 reg)
@@ -1273,19 +1273,16 @@ static int fimc_probe(struct platform_device *pdev)
if (exynos_drm_check_fimc_device(dev) != 0)
return -ENODEV;
- ctx = devm_kzalloc_obj(dev, *ctx);
+ num_formats = ARRAY_SIZE(fimc_formats) + ARRAY_SIZE(fimc_tiled_formats);
+ ctx = devm_kzalloc_flex(dev,*ctx, formats, num_formats);
if (!ctx)
return -ENOMEM;
+ ctx->num_formats = num_formats;
+ formats = ctx->formats;
ctx->dev = dev;
ctx->id = of_alias_get_id(dev->of_node, "fimc");
- /* construct formats/limits array */
- num_formats = ARRAY_SIZE(fimc_formats) + ARRAY_SIZE(fimc_tiled_formats);
- formats = devm_kzalloc_objs(dev, *formats, num_formats);
- if (!formats)
- return -ENOMEM;
-
/* linear formats */
if (ctx->id < 3) {
limits = fimc_4210_limits_v1;
@@ -1319,9 +1316,6 @@ static int fimc_probe(struct platform_device *pdev)
formats[j].num_limits = num_limits;
}
- ctx->formats = formats;
- ctx->num_formats = num_formats;
-
/* resource memory */
ctx->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ctx->regs))
--
2.56.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-11 22:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 22:01 [PATCH v2] drm/exynos: fimc: allocate formats as a flexible array member 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®