]> git.karo-electronics.de Git - karo-tx-linux.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)
commitd5d24bcc0a10a755ee77149e2f311c4ddafc19db
tree0f6a7162c45ffd3c6b6a758ffc567958b42762ae
parentdfebd8d81dc69afa9f20459ec9839f857f8c135f
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