diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-07-03 04:55:40 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-07-08 15:02:24 -0400 |
commit | 46b24311ccc8b37da9e6e006c6158229a5354268 (patch) | |
tree | 7ff47f0e57a889c74331e6a903ab2f6acbcedd88 /drivers/iio/industrialio-event.c | |
parent | a91aff1c09fc41a55ccaa115763ff77e36b527d3 (diff) |
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.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index b49059de5d02..fa6543bf6731 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) | |||
345 | { | 345 | { |
346 | int j, ret, attrcount = 0; | 346 | int j, ret, attrcount = 0; |
347 | 347 | ||
348 | INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list); | ||
349 | /* Dynically created from the channels array */ | 348 | /* Dynically created from the channels array */ |
350 | for (j = 0; j < indio_dev->num_channels; j++) { | 349 | for (j = 0; j < indio_dev->num_channels; j++) { |
351 | ret = iio_device_add_event_sysfs(indio_dev, | 350 | ret = iio_device_add_event_sysfs(indio_dev, |
@@ -396,6 +395,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev) | |||
396 | goto error_ret; | 395 | goto error_ret; |
397 | } | 396 | } |
398 | 397 | ||
398 | INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list); | ||
399 | |||
399 | iio_setup_ev_int(indio_dev->event_interface); | 400 | iio_setup_ev_int(indio_dev->event_interface); |
400 | if (indio_dev->info->event_attrs != NULL) { | 401 | if (indio_dev->info->event_attrs != NULL) { |
401 | attr = indio_dev->info->event_attrs->attrs; | 402 | attr = indio_dev->info->event_attrs->attrs; |