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 <kees@kernel.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
Gustavo A. R. Silva
2025-04-22 09:45:39 -06:00
committed by Danilo Krummrich
parent b7435cf2d9
commit c48b28e4ef

View File

@@ -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;