Skip to content

Commit 8fddc4b

Browse files
GustavoARSilvakees
authored andcommitted
drm/gud: Use size_add() in call to struct_size()
If, for any reason, the open-coded arithmetic causes a wraparound, the protection that `struct_size()` adds against potential integer overflows is defeated. Fix this by hardening call to `struct_size()` with `size_add()`. Fixes: 40e1a70 ("drm: Add GUD USB Display driver") Signed-off-by: "Gustavo A. R. Silva" <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/ZQSlyHKPdw/zsy4c@work Signed-off-by: Kees Cook <[email protected]>
1 parent 6b343a4 commit 8fddc4b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/gud/gud_pipe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ int gud_pipe_check(struct drm_simple_display_pipe *pipe,
503503
return -ENOENT;
504504

505505
len = struct_size(req, properties,
506-
GUD_PROPERTIES_MAX_NUM + GUD_CONNECTOR_PROPERTIES_MAX_NUM);
506+
size_add(GUD_PROPERTIES_MAX_NUM, GUD_CONNECTOR_PROPERTIES_MAX_NUM));
507507
req = kzalloc(len, GFP_KERNEL);
508508
if (!req)
509509
return -ENOMEM;

0 commit comments

Comments
 (0)