Prevent out-of-range register accesses.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
{
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;
{
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;
}