[PATCH 2/2] drm/imagination: Use struct_size_t()
Alessio Belle
Alessio.Belle at imgtec.com
Tue Jul 15 16:28:57 UTC 2025
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 at imgtec.com>
Reviewed-by: Alessio Belle <alessio.belle at 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)
>
More information about the dri-devel
mailing list