Skip to content

Commit

Permalink
[media] radio-mr800: fix locking order
Browse files Browse the repository at this point in the history
Don't hold the lock before unregistering the device, since when the
device is unregistered the datastruct containing the lock may be freed
(if the refcount went to 0).

Also fixed the framework documentation that erroneously suggested the
wrong locking order as well.

Reported-by: David Ellingsworth <david@identd.dyndns.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: David Ellingsworth <david@identd.dyndns.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Oct 21, 2010
1 parent 1cd7278 commit 9c84d89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Documentation/video4linux/v4l2-framework.txt
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ also waits in the code, then you should do the same to allow other processes
to access the device node while the first process is waiting for something.

The implementation of a hotplug disconnect should also take the lock before
calling v4l2_device_disconnect and video_unregister_device.
calling v4l2_device_disconnect.

video_device registration
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-mr800.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ static void usb_amradio_disconnect(struct usb_interface *intf)

mutex_lock(&radio->lock);
v4l2_device_disconnect(&radio->v4l2_dev);
video_unregister_device(&radio->videodev);
mutex_unlock(&radio->lock);
video_unregister_device(&radio->videodev);
}

/* vidioc_querycap - query device capabilities */
Expand Down

0 comments on commit 9c84d89

Please sign in to comment.