aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-07 13:12:48 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-14 11:45:25 -0400
commitf1a503dddf4d4da2b7bbf6ae4e92527bdc265bb9 (patch)
tree66c132ca66a00c29bc847aac12ba34b081bb92d8 /drivers/media/usb
parentfa86c9a1fca5a50563cc63e97aa130a3c54f1d4c (diff)
[media] gp8psk: don't go past the buffer size
Add checks to avoid going out of the buffer. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/dvb-usb/gp8psk.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/media/usb/dvb-usb/gp8psk.c b/drivers/media/usb/dvb-usb/gp8psk.c
index 807f5628a3bb..adfd76491451 100644
--- a/drivers/media/usb/dvb-usb/gp8psk.c
+++ b/drivers/media/usb/dvb-usb/gp8psk.c
@@ -60,6 +60,9 @@ int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8
60 struct gp8psk_state *st = d->priv; 60 struct gp8psk_state *st = d->priv;
61 int ret = 0,try = 0; 61 int ret = 0,try = 0;
62 62
63 if (blen > sizeof(st->data))
64 return -EIO;
65
63 if ((ret = mutex_lock_interruptible(&d->usb_mutex))) 66 if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
64 return ret; 67 return ret;
65 68
@@ -98,6 +101,9 @@ int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
98 deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); 101 deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index);
99 debug_dump(b,blen,deb_xfer); 102 debug_dump(b,blen,deb_xfer);
100 103
104 if (blen > sizeof(st->data))
105 return -EIO;
106
101 if ((ret = mutex_lock_interruptible(&d->usb_mutex))) 107 if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
102 return ret; 108 return ret;
103 109
@@ -151,6 +157,11 @@ static int gp8psk_load_bcm4500fw(struct dvb_usb_device *d)
151 err("failed to load bcm4500 firmware."); 157 err("failed to load bcm4500 firmware.");
152 goto out_free; 158 goto out_free;
153 } 159 }
160 if (buflen > 64) {
161 err("firmare chunk size bigger than 64 bytes.");
162 goto out_free;
163 }
164
154 memcpy(buf, ptr, buflen); 165 memcpy(buf, ptr, buflen);
155 if (dvb_usb_generic_write(d, buf, buflen)) { 166 if (dvb_usb_generic_write(d, buf, buflen)) {
156 err("failed to load bcm4500 firmware."); 167 err("failed to load bcm4500 firmware.");