diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index 3e5393e00b43..09b8db6d7ba3 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -971,6 +971,9 @@ struct xe_bo *__xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo, /* Only kernel objects should set GT */ XE_BUG_ON(gt && type != ttm_bo_type_kernel); + if (XE_WARN_ON(!size)) + return ERR_PTR(-EINVAL); + if (!bo) { bo = xe_bo_alloc(); if (IS_ERR(bo)) @@ -1524,6 +1527,9 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data, if (XE_IOCTL_ERR(xe, args->handle)) return -EINVAL; + if (XE_IOCTL_ERR(xe, !args->size)) + return -EINVAL; + if (XE_IOCTL_ERR(xe, args->size > SIZE_MAX)) return -EINVAL;