From c48b28e4ef7ba78ee105e0b188472be72c4107e2 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 22 Apr 2025 09:45:39 -0600 Subject: [PATCH] drm/nouveau: outp: Use __member_size() helper Use __member_size() to get the size of the flex-array member at compile time, instead of the convoluted expression `__struct_size(p) - sizeof(*p)` Link: https://lore.kernel.org/r/aAe5o_-f5OYSTXjZ@kspp Reviewed-by: Kees Cook Signed-off-by: Gustavo A. R. Silva Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nouveau/nvif/outp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c index 1ea20b2bdd29..32f6c5eb92af 100644 --- a/drivers/gpu/drm/nouveau/nvif/outp.c +++ b/drivers/gpu/drm/nouveau/nvif/outp.c @@ -198,7 +198,7 @@ nvif_outp_hda_eld(struct nvif_outp *outp, int head, void *data, u32 size) DEFINE_RAW_FLEX(struct nvif_outp_hda_eld_v0, mthd, data, 128); int ret; - if (WARN_ON(size > (__struct_size(mthd) - sizeof(*mthd)))) + if (WARN_ON(size > __member_size(mthd->data))) return -EINVAL; mthd->version = 0; -- 2.50.1