Skip to content

Commit b5c5baa

Browse files
Nikita Zhandarovichalexdeucher
authored andcommitted
drm/radeon/r100: Fix integer overflow issues in r100_cs_track_check()
It may be possible, albeit unlikely, to encounter integer overflow during the multiplication of several unsigned int variables, the result being assigned to a variable 'size' of wider type. Prevent this potential behaviour by converting one of the multiples to unsigned long. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 0242f74 ("drm/radeon: clean up CS functions in r100.c") Signed-off-by: Nikita Zhandarovich <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 39c960b commit b5c5baa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/radeon/r100.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,7 +2321,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
23212321
switch (prim_walk) {
23222322
case 1:
23232323
for (i = 0; i < track->num_arrays; i++) {
2324-
size = track->arrays[i].esize * track->max_indx * 4;
2324+
size = track->arrays[i].esize * track->max_indx * 4UL;
23252325
if (track->arrays[i].robj == NULL) {
23262326
DRM_ERROR("(PW %u) Vertex array %u no buffer "
23272327
"bound\n", prim_walk, i);
@@ -2340,7 +2340,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
23402340
break;
23412341
case 2:
23422342
for (i = 0; i < track->num_arrays; i++) {
2343-
size = track->arrays[i].esize * (nverts - 1) * 4;
2343+
size = track->arrays[i].esize * (nverts - 1) * 4UL;
23442344
if (track->arrays[i].robj == NULL) {
23452345
DRM_ERROR("(PW %u) Vertex array %u no buffer "
23462346
"bound\n", prim_walk, i);

0 commit comments

Comments
 (0)