• Hans Verkuil's avatar
    [media] vb2: fix nasty vb2_thread regression · fac710e4
    Hans Verkuil authored
    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: stable@vger.kernel.org # Kernel >= 4.3
    Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
    Reported-by: default avatarMatthias Schwarzott <zzam@gentoo.org>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
    fac710e4
Name
Last commit
Last update
..
blackfin Loading commit data...
davinci Loading commit data...
drv-intf Loading commit data...
i2c Loading commit data...
i2c-addr.h Loading commit data...
lirc.h Loading commit data...
lirc_dev.h Loading commit data...
media-device.h Loading commit data...
media-devnode.h Loading commit data...
media-entity.h Loading commit data...
rc-core.h Loading commit data...
rc-map.h Loading commit data...
soc_camera.h Loading commit data...
tuner-types.h Loading commit data...
tuner.h Loading commit data...
tveeprom.h Loading commit data...
v4l2-async.h Loading commit data...
v4l2-clk.h Loading commit data...
v4l2-common.h Loading commit data...
v4l2-ctrls.h Loading commit data...
v4l2-dev.h Loading commit data...
v4l2-device.h Loading commit data...
v4l2-dv-timings.h Loading commit data...
v4l2-event.h Loading commit data...
v4l2-fh.h Loading commit data...
v4l2-flash-led-class.h Loading commit data...
v4l2-image-sizes.h Loading commit data...
v4l2-ioctl.h Loading commit data...
v4l2-mediabus.h Loading commit data...
v4l2-mem2mem.h Loading commit data...
v4l2-of.h Loading commit data...
v4l2-subdev.h Loading commit data...
videobuf-core.h Loading commit data...
videobuf-dma-contig.h Loading commit data...
videobuf-dma-sg.h Loading commit data...
videobuf-dvb.h Loading commit data...
videobuf-vmalloc.h Loading commit data...
videobuf2-core.h Loading commit data...
videobuf2-dma-contig.h Loading commit data...
videobuf2-dma-sg.h Loading commit data...
videobuf2-dvb.h Loading commit data...
videobuf2-memops.h Loading commit data...
videobuf2-v4l2.h Loading commit data...
videobuf2-vmalloc.h Loading commit data...