[media] cx18: fix register range check
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 29 May 2013 10:00:08 +0000 (07:00 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 17 Jun 2013 12:15:43 +0000 (09:15 -0300)
Ensure that the register is aligned to a dword, otherwise the range check
could fail since it assumes dword alignment.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/pci/cx18/cx18-ioctl.c

index 414b0ecccc91c06b81d3b1ab4bdfed7c464d1c9d..1110bcb14e2f680a9436b1af21a21546bb2413b2 100644 (file)
@@ -367,6 +367,8 @@ static int cx18_g_register(struct file *file, void *fh,
 {
        struct cx18 *cx = fh2id(fh)->cx;
 
+       if (reg->reg & 0x3)
+               return -EINVAL;
        if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE)
                return -EINVAL;
        reg->size = 4;
@@ -379,6 +381,8 @@ static int cx18_s_register(struct file *file, void *fh,
 {
        struct cx18 *cx = fh2id(fh)->cx;
 
+       if (reg->reg & 0x3)
+               return -EINVAL;
        if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE)
                return -EINVAL;
        cx18_write_enc(cx, reg->val, reg->reg);