diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index 82affaedf067..42833ec0020f 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c @@ -333,6 +333,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo unsigned char readbuf[RDS_BUFFER]; int i = 0; + if (count > RDS_BUFFER) + return -EFAULT; mutex_lock(&dev->lock); if (dev->rdsstat == 0) cadet_start_rds(dev); @@ -349,8 +351,9 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo readbuf[i++] = dev->rdsbuf[dev->rdsout++]; mutex_unlock(&dev->lock); - if (i && copy_to_user(data, readbuf, i)) - return -EFAULT; + if (i > sizeof(readbuf) || (i && copy_to_user(data, readbuf, i))) + i = -EFAULT; + return i; } diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 5a503a6bb8c5..f75b1f831b81 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1715,7 +1715,7 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) goto exit; ret = rtl28xxu_rd_reg(d, IR_RX_BC, &buf[0]); - if (ret) + if (ret || buf[0] > sizeof(buf)) goto err; len = buf[0];