summaryrefslogtreecommitdiff
path: root/drivers/media/video/saa7164/saa7164-encoder.c
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2010-07-31 15:11:59 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-21 07:54:53 -0200
commit46eeb8dd30d3651e6ea55c2e60594206cd591d79 (patch)
treeec3d2d34b7f6e7c68aadec8aca8091e213e274c4 /drivers/media/video/saa7164/saa7164-encoder.c
parent58acca1056434dbbbcb3f1aacd759f1039a3169d (diff)
downloadlwn-46eeb8dd30d3651e6ea55c2e60594206cd591d79.tar.gz
lwn-46eeb8dd30d3651e6ea55c2e60594206cd591d79.zip
[media] saa7164: add guard bytes around critical buffers to detect failure
If the guard bytes are trampled then we have a memory related problem. Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7164/saa7164-encoder.c')
-rw-r--r--drivers/media/video/saa7164/saa7164-encoder.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c
index 5f73ceded31b..c61907d0efb9 100644
--- a/drivers/media/video/saa7164/saa7164-encoder.c
+++ b/drivers/media/video/saa7164/saa7164-encoder.c
@@ -1038,14 +1038,18 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
saa7164_histogram_update(&port->read_interval,
port->last_read_msecs_diff);
- if (*pos)
+ if (*pos) {
+ printk(KERN_ERR "%s() ESPIPE\n", __func__);
return -ESPIPE;
+ }
if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) {
if (atomic_inc_return(&port->v4l_reader_count) == 1) {
- if (saa7164_encoder_initialize(port) < 0)
+ if (saa7164_encoder_initialize(port) < 0) {
+ printk(KERN_ERR "%s() EINVAL\n", __func__);
return -EINVAL;
+ }
saa7164_encoder_start_streaming(port);
msleep(200);
@@ -1056,6 +1060,7 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
if ((file->f_flags & O_NONBLOCK) == 0) {
if (wait_event_interruptible(port->wait_read,
saa7164_enc_next_buf(port))) {
+ printk(KERN_ERR "%s() ERESTARTSYS\n", __func__);
return -ERESTARTSYS;
}
}
@@ -1077,8 +1082,10 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
if (copy_to_user(buffer, p, cnt)) {
printk(KERN_ERR "%s() copy_to_user failed\n", __func__);
- if (!ret)
+ if (!ret) {
+ printk(KERN_ERR "%s() EFAULT\n", __func__);
ret = -EFAULT;
+ }
goto err;
}
@@ -1087,6 +1094,10 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
buffer += cnt;
ret += cnt;
+ if (ubuf->pos > ubuf->actual_size) {
+ printk(KERN_ERR "read() pos > actual, huh?\n");
+ }
+
if (ubuf->pos == ubuf->actual_size) {
/* finished with current buffer, take next buffer */
@@ -1109,8 +1120,10 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
}
}
err:
- if (!ret && !ubuf)
+ if (!ret && !ubuf) {
+ printk(KERN_ERR "%s() EAGAIN\n", __func__);
ret = -EAGAIN;
+ }
return ret;
}