mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-13 01:08:50 +00:00
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 <michael.hennerich@analog.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e553f182d5
commit
0f1acee5f5
@ -854,6 +854,8 @@ static const struct file_operations iio_buffer_fileops = {
|
|||||||
.compat_ioctl = iio_ioctl,
|
.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 iio_device_register(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -882,6 +884,10 @@ int iio_device_register(struct iio_dev *indio_dev)
|
|||||||
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
|
if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
|
||||||
iio_device_register_trigger_consumer(indio_dev);
|
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);
|
ret = device_add(&indio_dev->dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error_unreg_eventset;
|
goto error_unreg_eventset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user