summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-05-29 07:00:00 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-17 08:53:48 -0300
commitd2cac168160aa7afd472d4a04d0da3f146243710 (patch)
treee3cb6db23cc8060f882fd91d6b35ba355a909375
parentb83007024219c0135aa18ca5e756b3935c3b8e31 (diff)
downloadlinux-d2cac168160aa7afd472d4a04d0da3f146243710.tar.gz
linux-d2cac168160aa7afd472d4a04d0da3f146243710.tar.bz2
linux-d2cac168160aa7afd472d4a04d0da3f146243710.zip
[media] mxb: check register address when reading/writing a register
Prevent out-of-range register accesses. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/pci/saa7146/mxb.c4
1 files changed, 4 insertions, 0 deletions
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;
}