Skip to content

Commit

Permalink
drm: prevent a harmless integer overflow in drm_legacy_sg_alloc()
Browse files Browse the repository at this point in the history
There is an integer overflow when we round up to PAGE_SIZE, but it's
harmless because we never re-use "request->size" for anything meaningful.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20200228092321.axulddmkxrujkmas@kili.mountain
  • Loading branch information
Dan Carpenter authored and Daniel Vetter committed Feb 28, 2020
1 parent df0e7f7 commit abdd768
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/gpu/drm/drm_scatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
if (!drm_core_check_feature(dev, DRIVER_SG))
return -EOPNOTSUPP;

if (request->size > SIZE_MAX - PAGE_SIZE)
return -EINVAL;

if (dev->sg)
return -EINVAL;

Expand Down

0 comments on commit abdd768

Please sign in to comment.