From: Hans Verkuil Date: Wed, 29 May 2013 10:00:00 +0000 (-0300) Subject: upstream: [media] mxb: check register address when reading/writing a register X-Git-Tag: submit/tizen/20141121.110247~2216 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddb98a5d1b3fac6e3dc1ca427746446fe52c86a2;p=platform%2Fkernel%2Flinux-3.10.git upstream: [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 8d17769..33abe33 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; }