Skip to content

Commit 69848cd

Browse files
Dan CarpenterAlex Williamson
authored andcommitted
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: 6724728 ("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>
1 parent 09699e5 commit 69848cd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/vfio/fsl-mc/vfio_fsl_mc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ static int vfio_fsl_mc_mmap(void *device_data, struct vm_area_struct *vma)
472472
{
473473
struct vfio_fsl_mc_device *vdev = device_data;
474474
struct fsl_mc_device *mc_dev = vdev->mc_dev;
475-
int index;
475+
unsigned int index;
476476

477477
index = vma->vm_pgoff >> (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT);
478478

0 commit comments

Comments
 (0)