From: Christian König Date: Thu, 8 Oct 2020 08:03:22 +0000 (+0200) Subject: dma-buf: use struct_size macro X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=82e1b93ad8b95a1667708164220ed137d6f3adfb;p=linux.git dma-buf: use struct_size macro Instead of manually calculating the structure size. Signed-off-by: Christian König Reviewed-by: Gustavo A. R. Silva Reviewed-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/394252/ --- diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 1c8f2581cb09a..bb5a42b10c290 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;