mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
[media] vb2: fix nasty vb2_thread regression
The vb2_thread implementation was made generic and was moved from
videobuf2-v4l2.c to videobuf2-core.c in commit af3bac1a. Unfortunately
that clearly was never tested since it broke read() causing NULL address
references.
The root cause was confused handling of vb2_buffer vs v4l2_buffer (the pb
pointer in various core functions).
The v4l2_buffer no longer exists after moving the code into the core and
it is no longer needed. However, the vb2_thread code passed a pointer to
a vb2_buffer to the core functions were a v4l2_buffer pointer was expected
and vb2_thread expected that the vb2_buffer fields would be filled in
correctly.
This is obviously wrong since v4l2_buffer != vb2_buffer. Note that the
pb pointer is a void pointer, so no type-checking took place.
This patch fixes this problem:
1) allow pb to be NULL for vb2_core_(d)qbuf. The vb2_thread code will use
a NULL pointer here since they don't care about v4l2_buffer anyway.
2) let vb2_core_dqbuf pass back the index of the received buffer. This is
all vb2_thread needs: this index is the index into the q->bufs array
and vb2_thread just gets the vb2_buffer from there.
3) the fileio->b pointer (that originally contained a v4l2_buffer) is
removed altogether since it is no longer needed.
Tested with vivid and the cobalt driver.
Cc: [email protected] # Kernel >= 4.3
Signed-off-by: Hans Verkuil <[email protected]>
Reported-by: Matthias Schwarzott <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
This commit is contained in:
parent
e8beb02343
commit
fac710e45d
3 changed files with 46 additions and 54 deletions
|
|
@ -533,7 +533,8 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
|
|||
const unsigned int requested_sizes[]);
|
||||
int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb);
|
||||
int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb);
|
||||
int vb2_core_dqbuf(struct vb2_queue *q, void *pb, bool nonblocking);
|
||||
int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
|
||||
bool nonblocking);
|
||||
|
||||
int vb2_core_streamon(struct vb2_queue *q, unsigned int type);
|
||||
int vb2_core_streamoff(struct vb2_queue *q, unsigned int type);
|
||||
|
|
|
|||
Loading…
Reference in a new issue