mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Coster <matt.coster@imgtec.com>
To: Frank Binns <frank.binns@imgtec.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	"Matt Coster" <matt.coster@imgtec.com>
Subject: [PATCH 0/2] drm/imagination: Fixes for flexible structures
Date: Wed, 9 Jul 2025 11:04:08 +0100	[thread overview]
Message-ID: <20250709-flex-array-check-v1-0-8adeb0bf0cde@imgtec.com> (raw)

These fixes were made as part of investigating the Sparse issue reported
in [1]; specifically that the sizeof() check for the flexible structure
struct rogue_fwif_frag_ctx_state was failing under Sparse.

This is actually a fairly pointless check, and the discrepancy is
related to the implicit padding at the end of the structure that is
never used due to the flexible array member. A far more useful check is
to assert that the final member is indeed a flexible array as expected,
and that one element of said array is of the size that we expect.

While fixing that, I stumbled on the useful struct_size_t() macro and
put it to good use wherever the size of the structure in question is
computed.

[1]: https://lore.kernel.org/r/20250606-sprase-reasoning-comments-v1-1-433c0ff11a09@imgtec.com

Signed-off-by: Matt Coster <matt.coster@imgtec.com>
---
Matt Coster (2):
      drm/imagination: Add and use FLEX_ARRAY_CHECK()
      drm/imagination: Use struct_size_t()

 drivers/gpu/drm/imagination/pvr_queue.c            | 11 +++++------
 drivers/gpu/drm/imagination/pvr_rogue_fwif_check.h | 19 ++++++++++++++++++-
 2 files changed, 23 insertions(+), 7 deletions(-)
---
base-commit: fe88fb3421161f3abd974ee2ecbe2d9195f98812
change-id: 20250704-flex-array-check-ac9c3b6f130e


             reply	other threads:[~2025-07-09 10:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 10:04 Matt Coster [this message]
2025-07-09 10:04 ` [PATCH 1/2] drm/imagination: Add and use FLEX_ARRAY_CHECK() Matt Coster
2025-07-15 15:48   ` Alessio Belle
2025-07-09 10:04 ` [PATCH 2/2] drm/imagination: Use struct_size_t() Matt Coster
2025-07-15 16:28   ` Alessio Belle
2026-07-20 13:40 ` [PATCH 0/2] drm/imagination: Fixes for flexible structures Alessio Belle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250709-flex-array-check-v1-0-8adeb0bf0cde@imgtec.com \
    --to=matt.coster@imgtec.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=frank.binns@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®