public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] drm/nouveau: outp: Use __member_size() helper
@ 2025-04-22 15:45 Gustavo A. R. Silva
  2025-04-22 15:49 ` Kees Cook
  2025-04-23 15:35 ` Danilo Krummrich
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2025-04-22 15:45 UTC (permalink / raw)
  To: Lyude Paul, Danilo Krummrich, David Airlie, Simona Vetter
  Cc: dri-devel, nouveau, linux-kernel, Gustavo A. R. Silva,
	linux-hardening

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)`

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 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.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-23 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 15:45 [PATCH][next] drm/nouveau: outp: Use __member_size() helper Gustavo A. R. Silva
2025-04-22 15:49 ` Kees Cook
2025-04-23 15:35 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox