Skip to content

Commit b266294

Browse files
Murray McAllistergregkh
authored andcommitted
drm/vmwgfx: NULL pointer dereference in vmw_surface_define_ioctl()
commit 36274ab8c596f1240c606bb514da329add2a1bcd upstream. 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. Signed-off-by: Murray McAllister <murray.mcallister@insomniasec.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ed52892 commit b266294

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

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

721-
if (num_sizes > DRM_VMW_MAX_SURFACE_FACES *
722-
DRM_VMW_MAX_MIP_LEVELS)
721+
if (num_sizes > DRM_VMW_MAX_SURFACE_FACES * DRM_VMW_MAX_MIP_LEVELS ||
722+
num_sizes == 0)
723723
return -EINVAL;
724724

725725
size = vmw_user_surface_size + 128 +

0 commit comments

Comments
 (0)