[media] drxk: Avoid OOPSes if firmware is corrupted
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 9 Jul 2011 21:57:54 +0000 (18:57 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 27 Jul 2011 20:55:48 +0000 (17:55 -0300)
Don't read paste the buffer, if the firmware is corrupted.
Instead, print an error message.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/frontends/drxk_hard.c

index c4b35a5638cddf45246938104b9e323efc1dbbc4..89db378358728c0763810e4290b5fed365c46ea4 100644 (file)
@@ -1388,6 +1388,12 @@ static int DownloadMicrocode(struct drxk_state *state,
                BlockCRC = (pSrc[0] << 8) | pSrc[1];
                pSrc += sizeof(u16);
                offset += sizeof(u16);
+
+               if (offset + BlockSize > Length) {
+                       printk(KERN_ERR "drxk: Firmware is corrupted.\n");
+                       return -EINVAL;
+               }
+
                status = write_block(state, Address, BlockSize, pSrc);
                if (status < 0)
                        break;