summaryrefslogtreecommitdiff
path: root/drivers/lguest
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-09-18 21:02:00 +0100
committerJonathan Cameron <jic23@kernel.org>2013-09-21 12:50:23 +0100
commit0d5b7dae897b61a2372916b1c93f6cee6b8049b1 (patch)
treebfdaccfa0f8e614b42ebfa6e74871c1b653806ff /drivers/lguest
parentcadc2125e140f7122bf1b59d42486cfc778c7286 (diff)
iio: Prevent race between IIO chardev opening and IIO device free
Set the IIO device as the parent for the character device We need to make sure that the IIO device is not freed while the character device exists, otherwise the freeing of the IIO device might race against the file open callback. Do this by setting the character device's parent to the IIO device, this will cause the character device to grab a reference to the IIO device and only release it once the character device itself has been removed. Also move the registration of the character device before the registration of the IIO device to avoid the (rather theoretical case) that the IIO device is already freed again before we can add the character device and grab a reference to the IIO device. We also need to move the call to cdev_del() from iio_dev_release() to iio_device_unregister() (where it should have been in the first place anyway) to avoid a reference cycle. As iio_dev_release() is only called once all reference are dropped, but the character device holds a reference to the IIO device. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/lguest')
0 files changed, 0 insertions, 0 deletions