提交 4a82bc60 编写于 作者: H Hans de Goede 提交者: Mauro Carvalho Chehab

[media] gspca_main: Update buffer flags even when user_copy fails

Before this patch dqbuf errors out on a failing user_copy (with user pointers)
before updating the buffer flags, causing a successsfully dequeued buffer
to still have the DONE flag, which means that it could no longer be
re-queueud (assuming the app somehow survives the segfault).
Signed-off-by: NHans de Goede <hdegoede@redhat.com>
Acked-by: NJean-Francois Moine <moinejf@free.fr>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 27074efa
...@@ -1912,6 +1912,11 @@ static int vidioc_dqbuf(struct file *file, void *priv, ...@@ -1912,6 +1912,11 @@ static int vidioc_dqbuf(struct file *file, void *priv,
mutex_unlock(&gspca_dev->usb_lock); mutex_unlock(&gspca_dev->usb_lock);
} }
frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE;
memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf);
PDEBUG(D_FRAM, "dqbuf %d", j);
ret = 0;
if (gspca_dev->memory == V4L2_MEMORY_USERPTR) { if (gspca_dev->memory == V4L2_MEMORY_USERPTR) {
if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr, if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr,
frame->data, frame->data,
...@@ -1919,13 +1924,8 @@ static int vidioc_dqbuf(struct file *file, void *priv, ...@@ -1919,13 +1924,8 @@ static int vidioc_dqbuf(struct file *file, void *priv,
PDEBUG(D_ERR|D_STREAM, PDEBUG(D_ERR|D_STREAM,
"dqbuf cp to user failed"); "dqbuf cp to user failed");
ret = -EFAULT; ret = -EFAULT;
goto out;
} }
} }
frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE;
memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf);
PDEBUG(D_FRAM, "dqbuf %d", j);
ret = 0;
out: out:
mutex_unlock(&gspca_dev->queue_lock); mutex_unlock(&gspca_dev->queue_lock);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册