public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] drm/nouveau: disp: Use __member_size() helper
@ 2025-04-22 15:44 Gustavo A. R. Silva
  2025-04-22 15:49 ` Kees Cook
  2025-04-23 15:34 ` Danilo Krummrich
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2025-04-22 15:44 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/dispnv50/disp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 725331638a15..9bed728cb00e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -776,7 +776,7 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,
 	const u8 rekey = 56; /* binary driver, and tegra, constant */
 	u32 max_ac_packet;
 	DEFINE_RAW_FLEX(struct nvif_outp_infoframe_v0, args, data, 17);
-	const u8 data_len = __struct_size(args) - sizeof(*args);
+	const u8 data_len = __member_size(args->data);
 	int ret, size;
 
 	max_ac_packet  = mode->htotal - mode->hdisplay;
-- 
2.43.0


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

* Re: [PATCH][next] drm/nouveau: disp: Use __member_size() helper
  2025-04-22 15:44 [PATCH][next] drm/nouveau: disp: Use __member_size() helper Gustavo A. R. Silva
@ 2025-04-22 15:49 ` Kees Cook
  2025-04-23 15:34 ` Danilo Krummrich
  1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2025-04-22 15:49 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Lyude Paul, Danilo Krummrich, David Airlie, Simona Vetter,
	dri-devel, nouveau, linux-kernel, linux-hardening

On Tue, Apr 22, 2025 at 09:44:56AM -0600, Gustavo A. R. Silva wrote:
> 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>

Reviewed-by: Kees Cook <kees@kernel.org>

-- 
Kees Cook

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

* Re: [PATCH][next] drm/nouveau: disp: Use __member_size() helper
  2025-04-22 15:44 [PATCH][next] drm/nouveau: disp: Use __member_size() helper Gustavo A. R. Silva
  2025-04-22 15:49 ` Kees Cook
@ 2025-04-23 15:34 ` Danilo Krummrich
  1 sibling, 0 replies; 3+ messages in thread
From: Danilo Krummrich @ 2025-04-23 15:34 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Lyude Paul, David Airlie, Simona Vetter, dri-devel, nouveau,
	linux-kernel, linux-hardening

On Tue, Apr 22, 2025 at 09:44:56AM -0600, Gustavo A. R. Silva wrote:
> 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>

Applied to drm-misc-next, thanks!

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

end of thread, other threads:[~2025-04-23 15:34 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:44 [PATCH][next] drm/nouveau: disp: Use __member_size() helper Gustavo A. R. Silva
2025-04-22 15:49 ` Kees Cook
2025-04-23 15:34 ` Danilo Krummrich

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