]> git.baikalelectronics.ru Git - kernel.git/commit
iio: trigger: close race condition in acquiring trigger reference
authorAlison Schofield <amsfield22@gmail.com>
Sun, 22 Jan 2017 03:28:52 +0000 (19:28 -0800)
committerJonathan Cameron <jic23@kernel.org>
Sun, 22 Jan 2017 13:21:41 +0000 (13:21 +0000)
commitea7fef4fc6154f7781706cbd9f2070639b2f35e7
tree0f6a7162c45ffd3c6b6a758ffc567958b42762ae
parent6c1029a53821779e9ca752e579a2dcb7488b6ff1
iio: trigger: close race condition in acquiring trigger reference

In iio_trigger_write_current() we find the trigger we want while
holding mutex on the list of triggers, but we don't actually do a
get on it while holding mutex.  We wait until further validations
are completed and we're sure it's the one we want.  Race condition
is that it could be freed by the time we do the get.

Solution is to grab the trigger (iio_trigger_get) as soon as we
find it while holding mutex on the list of triggers.  If later
we decide it's not the right one, put it back. (iio_trigger_put).

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/industrialio-trigger.c