From: Hans Verkuil Date: Wed, 29 May 2013 10:00:00 +0000 (-0300) Subject: [media] mxb: check register address when reading/writing a register X-Git-Tag: firefly_0821_release~176^2~3573^2~1750 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d2cac168160aa7afd472d4a04d0da3f146243710;p=firefly-linux-kernel-4.4.55.git [media] mxb: check register address when reading/writing a register Prevent out-of-range register accesses. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 8d177691cd7c..33abe332d175 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -669,6 +669,8 @@ static int vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_regist { struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + if (reg->reg > pci_resource_len(dev->pci, 0) - 4) + return -EINVAL; reg->val = saa7146_read(dev, reg->reg); reg->size = 4; return 0; @@ -678,6 +680,8 @@ static int vidioc_s_register(struct file *file, void *fh, const struct v4l2_dbg_ { struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + if (reg->reg > pci_resource_len(dev->pci, 0) - 4) + return -EINVAL; saa7146_write(dev, reg->reg, reg->val); return 0; }