Commit c48b28e4 authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Danilo Krummrich
Browse files

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: default avatarKees Cook <kees@kernel.org>
Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent b7435cf2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;