summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBrian Masney <masneyb@onstation.org>2016-09-27 03:20:18 +0300
committerJonathan Cameron <jic23@kernel.org>2016-10-01 16:53:51 +0300
commit5faf98cb319bc7ce7cef080be1bbebba44233332 (patch)
tree1666f6a73c938dc8850211d5bc8c3791db714aab /drivers
parent028199660d8f53f1856bbe8cf6771d3351eaa182 (diff)
downloadlinux-5faf98cb319bc7ce7cef080be1bbebba44233332.tar.xz
staging: iio: isl29018: fixed race condition in in_illuminance_scale_available_show()
in_illuminance_scale_available_show() references the isl29018_chip->int_time variable in three places inside a for loop. The value of the int_time variable can be updated by the isl29018_set_integration_time() function, which is called by the isl29018_write_raw() function. isl29018_write_raw() locks a mutex specific to this driver when the integration time variable is updated. Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/iio/light/isl29018.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index 19f282c13651..990c6e52bafe 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -277,10 +277,12 @@ static ssize_t in_illuminance_scale_available_show
unsigned int i;
int len = 0;
+ mutex_lock(&chip->lock);
for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i)
len += sprintf(buf + len, "%d.%06d ",
isl29018_scales[chip->int_time][i].scale,
isl29018_scales[chip->int_time][i].uscale);
+ mutex_unlock(&chip->lock);
buf[len - 1] = '\n';