• Laurent Pinchart's avatar
    [media] v4l: Don't access media entity after is has been destroyed · c064b8ea
    Laurent Pinchart authored
    Entities associated with video device nodes are unregistered in
    video_unregister_device(). This destroys the entity even though it can
    still be accessed through open video device nodes.
    
    Move the media_device_unregister_entity() call from
    video_unregister_device() to v4l2_device_release() to ensure that the
    entity isn't unregistered until the last reference to the video device
    is released.
    
    Also remove the media_entity_get()/put() calls from v4l2-dev.c. Those
    functions were designed for subdevs, to avoid a parent module from being
    removed while still accessible through board code. They're not currently
    needed for video device nodes, and will oops when a hotpluggable device
    is disconnected during streaming, as media_entity_put() called in
    v4l2_device_release() tries to access entity->parent->dev->driver which
    is set to NULL when the device is disconnected.
    Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
    Acked-by: default avatarSakari Ailus <sakari.ailus@iki.fi>
    Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
    c064b8ea
v4l2-dev.c 21 KB