Commit 74c1bda2 authored by Colin Ian King's avatar Colin Ian King Committed by Gerd Hoffmann

drm/virtio: fix another potential integer overflow on shift of a int

The left shift of unsigned int 32 bit integer constant 1 is evaluated
using 32 bit arithmetic and then assigned to a signed 64 bit integer.
In the case where value is 32 or more this can lead to an overflow
(value can be in range 0..MAX_CAPSET_ID (63). Fix this by shifting
the value 1ULL instead.

Addresses-Coverity: ("Uninitentional integer overflow")
Fixes: 4fb530e5 ("drm/virtio: implement context init: support init ioctl")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210930102748.16922-1-colin.king@canonical.comSigned-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 8f4502fa
......@@ -774,7 +774,7 @@ static int virtio_gpu_context_init_ioctl(struct drm_device *dev,
goto out_unlock;
}
if ((vgdev->capset_id_mask & (1 << value)) == 0) {
if ((vgdev->capset_id_mask & (1ULL << value)) == 0) {
ret = -EINVAL;
goto out_unlock;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment