[PATCH] dma-buf: use struct_size macro
Daniel Vetter
daniel at ffwll.ch
Thu Oct 8 08:17:37 UTC 2020
On Thu, Oct 8, 2020 at 10:10 AM Christian König
<ckoenig.leichtzumerken at gmail.com> wrote:
>
> Instead of manually calculating the structure size.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
> drivers/dma-buf/dma-resv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index 1c8f2581cb09..bb5a42b10c29 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -63,7 +63,7 @@ static struct dma_resv_list *dma_resv_list_alloc(unsigned int shared_max)
> {
> struct dma_resv_list *list;
>
> - list = kmalloc(offsetof(typeof(*list), shared[shared_max]), GFP_KERNEL);
> + list = kmalloc(struct_size(list, shared, shared_max), GFP_KERNEL);
> if (!list)
> return NULL;
>
> --
> 2.17.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the dri-devel
mailing list