]> git.karo-electronics.de Git - karo-tx-linux.git/commit
[media] v4l: Don't access media entity after is has been destroyed
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 15 Jun 2011 08:20:34 +0000 (05:20 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 1 Jul 2011 02:12:36 +0000 (23:12 -0300)
commitc064b8eac8da5d494fd221f14219c4f39502deb2
treef0c3c04d8ee9940d86076ffded0afa78dcca8e7b
parentca4186f06fecbf2b692a42cdea54b7ef23b2496c
[media] v4l: Don't access media entity after is has been destroyed

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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/v4l2-dev.c