Skip to content

Commit

Permalink
[PATCH] V4L: Fix read() bugs in bttv driver
Browse files Browse the repository at this point in the history
Fix read() bugs in bttv driver.

Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Nickolay V. Shmyrev authored and Linus Torvalds committed Dec 1, 2005
1 parent 3b86b99 commit 50ab5ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions drivers/media/video/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2952,6 +2952,8 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
field = videobuf_next_field(&fh->cap);
if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
kfree (fh->cap.read_buf);
fh->cap.read_buf = NULL;
up(&fh->cap.lock);
return POLLERR;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/media/video/video-buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,9 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
int retval;

/* setup stuff */
retval = -ENOMEM;
q->read_buf = videobuf_alloc(q->msize);
if (NULL == q->read_buf)
goto done;
return -ENOMEM;

q->read_buf->memory = V4L2_MEMORY_USERPTR;
q->read_buf->baddr = (unsigned long)data;
Expand Down Expand Up @@ -819,8 +818,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
q->read_buf->memory = V4L2_MEMORY_USERPTR;
field = videobuf_next_field(q);
retval = q->ops->buf_prepare(q,q->read_buf,field);
if (0 != retval)
if (0 != retval) {
kfree (q->read_buf);
q->read_buf = NULL;
goto done;
}
spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,q->read_buf);
spin_unlock_irqrestore(q->irqlock,flags);
Expand Down

0 comments on commit 50ab5ed

Please sign in to comment.