Skip to content

Commit 36274ab

Browse files
Murray McAllisterthomashvmw
authored andcommitted
drm/vmwgfx: NULL pointer dereference in vmw_surface_define_ioctl()
Before memory allocations vmw_surface_define_ioctl() checks the upper-bounds of a user-supplied size, but does not check if the supplied size is 0. Add check to avoid NULL pointer dereferences. Cc: <[email protected]> Signed-off-by: Murray McAllister <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
1 parent f7652af commit 36274ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
716716
for (i = 0; i < DRM_VMW_MAX_SURFACE_FACES; ++i)
717717
num_sizes += req->mip_levels[i];
718718

719-
if (num_sizes > DRM_VMW_MAX_SURFACE_FACES *
720-
DRM_VMW_MAX_MIP_LEVELS)
719+
if (num_sizes > DRM_VMW_MAX_SURFACE_FACES * DRM_VMW_MAX_MIP_LEVELS ||
720+
num_sizes == 0)
721721
return -EINVAL;
722722

723723
size = vmw_user_surface_size + 128 +

0 commit comments

Comments
 (0)