summaryrefslogtreecommitdiff
path: root/drivers/vfio/fsl-mc/vfio_fsl_mc.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2020-10-23 14:29:47 +0300
committerAlex Williamson <alex.williamson@redhat.com>2020-11-03 21:07:19 +0300
commit69848cd6f0c1fb4f82ab255b730343a215ded013 (patch)
tree42e2f57377c275cef4d7dfc99dfdef983f5a2771 /drivers/vfio/fsl-mc/vfio_fsl_mc.c
parent09699e56dee946a16767021af97411ed6f4b3e6b (diff)
downloadlinux-69848cd6f0c1fb4f82ab255b730343a215ded013.tar.xz
vfio/fsl-mc: prevent underflow in vfio_fsl_mc_mmap()
My static analsysis tool complains that the "index" can be negative. There are some checks in do_mmap() which try to prevent underflows but I don't know if they are sufficient for this situation. Either way, making "index" unsigned is harmless so let's do it just to be safe. Fixes: 67247289688d ("vfio/fsl-mc: Allow userspace to MMAP fsl-mc device MMIO regions") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Diana Craciun <diana.craciun@oss.nxp.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/fsl-mc/vfio_fsl_mc.c')
-rw-r--r--drivers/vfio/fsl-mc/vfio_fsl_mc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
index 21f22e3da11f..f27e25112c40 100644
--- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
+++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
@@ -472,7 +472,7 @@ static int vfio_fsl_mc_mmap(void *device_data, struct vm_area_struct *vma)
{
struct vfio_fsl_mc_device *vdev = device_data;
struct fsl_mc_device *mc_dev = vdev->mc_dev;
- int index;
+ unsigned int index;
index = vma->vm_pgoff >> (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT);