Skip to content

Commit 4f88b4c

Browse files
GustavoARSilvaRoland Scheidegger
authored andcommitted
drm/vmwgfx: Use struct_size() helper
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. This code was detected with the help of Coccinelle and, audited and fixed manually. Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Roland Scheidegger <[email protected]>
1 parent dc100bc commit 4f88b4c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ static int vmw_surface_dirty_alloc(struct vmw_resource *res)
19691969
num_mip = 1;
19701970

19711971
num_subres = num_layers * num_mip;
1972-
dirty_size = sizeof(*dirty) + num_subres * sizeof(dirty->boxes[0]);
1972+
dirty_size = struct_size(dirty, boxes, num_subres);
19731973
acc_size = ttm_round_pot(dirty_size);
19741974
ret = ttm_mem_global_alloc(vmw_mem_glob(res->dev_priv),
19751975
acc_size, &ctx);

0 commit comments

Comments
 (0)