From: Michael Hennerich Date: Thu, 1 Mar 2012 09:51:04 +0000 (+0100) Subject: staging: iio: core: Avoid NULL pointer de-ref in case indio_dev->setup_ops are not... X-Git-Tag: MMI-PSA29.97-13-9~17268^2~83 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0f1acee5f5e2ceaef3244dc4c1f3895b907669cd;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git staging: iio: core: Avoid NULL pointer de-ref in case indio_dev->setup_ops are not in use Drivers may not need setup_ops at all, so let the core supply some empty ops. Signed-off-by: Michael Hennerich Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 868e36672001..27695dffb177 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -854,6 +854,8 @@ static const struct file_operations iio_buffer_fileops = { .compat_ioctl = iio_ioctl, }; +static const struct iio_buffer_setup_ops noop_ring_setup_ops; + int iio_device_register(struct iio_dev *indio_dev) { int ret; @@ -882,6 +884,10 @@ int iio_device_register(struct iio_dev *indio_dev) if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) iio_device_register_trigger_consumer(indio_dev); + if ((indio_dev->modes & INDIO_ALL_BUFFER_MODES) && + indio_dev->setup_ops == NULL) + indio_dev->setup_ops = &noop_ring_setup_ops; + ret = device_add(&indio_dev->dev); if (ret < 0) goto error_unreg_eventset;