summaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-event.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-07-03 10:55:40 +0200
committerJonathan Cameron <jic23@kernel.org>2012-07-08 20:02:24 +0100
commit46b24311ccc8b37da9e6e006c6158229a5354268 (patch)
tree7ff47f0e57a889c74331e6a903ab2f6acbcedd88 /drivers/iio/industrialio-event.c
parenta91aff1c09fc41a55ccaa115763ff77e36b527d3 (diff)
downloadop-kernel-dev-46b24311ccc8b37da9e6e006c6158229a5354268.zip
op-kernel-dev-46b24311ccc8b37da9e6e006c6158229a5354268.tar.gz
iio: Fix unitialized use of list
The dev_attr list is initialized in __iio_add_event_config_attrs which is called only when indio_dev->channels is true. Nevertheless the list is used unconditionally later in iio_device_register_eventset which results in a NULL pointer exception. To fix this unconditionally initialize the list in iio_device_register_eventset. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-event.c')
-rw-r--r--drivers/iio/industrialio-event.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index b49059d..fa6543b 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -345,7 +345,6 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev)
{
int j, ret, attrcount = 0;
- INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list);
/* Dynically created from the channels array */
for (j = 0; j < indio_dev->num_channels; j++) {
ret = iio_device_add_event_sysfs(indio_dev,
@@ -396,6 +395,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
goto error_ret;
}
+ INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list);
+
iio_setup_ev_int(indio_dev->event_interface);
if (indio_dev->info->event_attrs != NULL) {
attr = indio_dev->info->event_attrs->attrs;
OpenPOWER on IntegriCloud