dma-buf: use struct_size macro
authorChristian König <christian.koenig@amd.com>
Thu, 8 Oct 2020 08:03:22 +0000 (10:03 +0200)
committerChristian König <christian.koenig@amd.com>
Thu, 8 Oct 2020 13:39:36 +0000 (15:39 +0200)
Instead of manually calculating the structure size.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/394252/
drivers/dma-buf/dma-resv.c

index 1c8f258..bb5a42b 100644 (file)
@@ -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;