[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>
This commit is contained in:
Hans Verkuil 2013-05-29 07:00:00 -03:00 committed by Mauro Carvalho Chehab
parent b830070242
commit d2cac16816

View File

@ -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;
}