mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alessio Belle <Alessio.Belle@imgtec.com>
To: Matt Coster <Matt.Coster@imgtec.com>
Cc: "tzimmermann@suse.de" <tzimmermann@suse.de>,
	"simona@ffwll.ch" <simona@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Frank Binns <Frank.Binns@imgtec.com>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"airlied@gmail.com" <airlied@gmail.com>
Subject: Re: [PATCH 2/2] drm/imagination: Use struct_size_t()
Date: Tue, 15 Jul 2025 16:28:57 +0000	[thread overview]
Message-ID: <7c2dcc953227e79bdabb4c7e4d071907c5ae643b.camel@imgtec.com> (raw)
In-Reply-To: <20250709-flex-array-check-v1-2-8adeb0bf0cde@imgtec.com>

On Wed, 2025-07-09 at 11:04 +0100, Matt Coster wrote:
> The helpers for dealing with flexible structures exist, so let's use them.
> 
> Signed-off-by: Matt Coster <matt.coster@imgtec.com>

Reviewed-by: Alessio Belle <alessio.belle@imgtec.com>

Thanks,
Alessio

> ---
>  drivers/gpu/drm/imagination/pvr_queue.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
> index 5a41ee79fed646a86344cd16e78efdb45ff02e43..094a854576a5a63f56e56acdebf01bdf542ae4d5 100644
> --- a/drivers/gpu/drm/imagination/pvr_queue.c
> +++ b/drivers/gpu/drm/imagination/pvr_queue.c
> @@ -3,6 +3,7 @@
>  
>  #include <drm/drm_managed.h>
>  #include <drm/gpu_scheduler.h>
> +#include <linux/overflow.h>
>  
>  #include "pvr_cccb.h"
>  #include "pvr_context.h"
> @@ -35,9 +36,8 @@ static int get_xfer_ctx_state_size(struct pvr_device *pvr_dev)
>  			return err;
>  	}
>  
> -	return sizeof(struct rogue_fwif_frag_ctx_state) +
> -	       (num_isp_store_registers *
> -		sizeof(((struct rogue_fwif_frag_ctx_state *)0)->frag_reg_isp_store[0]));
> +	return struct_size_t(struct rogue_fwif_frag_ctx_state,
> +			     frag_reg_isp_store, num_isp_store_registers);
>  }
>  
>  static int get_frag_ctx_state_size(struct pvr_device *pvr_dev)
> @@ -65,9 +65,8 @@ static int get_frag_ctx_state_size(struct pvr_device *pvr_dev)
>  			return err;
>  	}
>  
> -	return sizeof(struct rogue_fwif_frag_ctx_state) +
> -	       (num_isp_store_registers *
> -		sizeof(((struct rogue_fwif_frag_ctx_state *)0)->frag_reg_isp_store[0]));
> +	return struct_size_t(struct rogue_fwif_frag_ctx_state,
> +			     frag_reg_isp_store, num_isp_store_registers);
>  }
>  
>  static int get_ctx_state_size(struct pvr_device *pvr_dev, enum drm_pvr_job_type type)
> 


  reply	other threads:[~2025-07-15 16:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 10:04 [PATCH 0/2] drm/imagination: Fixes for flexible structures Matt Coster
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 [this message]
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=7c2dcc953227e79bdabb4c7e4d071907c5ae643b.camel@imgtec.com \
    --to=alessio.belle@imgtec.com \
    --cc=Frank.Binns@imgtec.com \
    --cc=Matt.Coster@imgtec.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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®