From d2cac168160aa7afd472d4a04d0da3f146243710 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 29 May 2013 07:00:00 -0300 Subject: [PATCH] [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 --- drivers/media/pci/saa7146/mxb.c | 4 ++++ 1 file changed, 4 insertions(+) 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; } -- 2.20.1