diff options
author | Jonathan Cameron <jic23@kernel.org> | 2012-02-15 19:48:00 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-02-24 12:10:02 -0800 |
commit | ac917a81117ce0286847666b55dd265f6cda8383 (patch) | |
tree | ea5052ebeb55cc59fc0f3fa28df1560ddfa487f3 /drivers/staging/iio/industrialio-core.c | |
parent | 08cd9ef4eca0b53cdae190b718e4945408c7d3b8 (diff) | |
download | linux-ac917a81117ce0286847666b55dd265f6cda8383.tar.bz2 |
staging:iio:core set the iio_dev.info pointer to null on unregister under lock.
This prevents use of provider callbacks after it has been unregistered.
Note that all code using this that can be called from a consumer *must*
check the pointer before using and hold the info_exist_lock throughout
the usage of the callbacks in info.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/iio/industrialio-core.c')
-rw-r--r-- | drivers/staging/iio/industrialio-core.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index e4824fe8b405..3a2d08026624 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -594,6 +594,7 @@ struct iio_dev *iio_allocate_device(int sizeof_priv) device_initialize(&dev->dev); dev_set_drvdata(&dev->dev, (void *)dev); mutex_init(&dev->mlock); + mutex_init(&dev->info_exist_lock); dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL); if (dev->id < 0) { @@ -718,6 +719,9 @@ EXPORT_SYMBOL(iio_device_register); void iio_device_unregister(struct iio_dev *indio_dev) { + mutex_lock(&indio_dev->info_exist_lock); + indio_dev->info = NULL; + mutex_unlock(&indio_dev->info_exist_lock); device_unregister(&indio_dev->dev); } EXPORT_SYMBOL(iio_device_unregister); |