Re: [PATCH 2/3] iio: core: Avoid NULL pointer de-ref in case indio_dev->setup_ops are not in use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/22/2012 12:30 PM, michael.hennerich@xxxxxxxxxx wrote:
> From: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
> 
> Drivers may not need setup_ops at all, so let the core supply
> some empty ops.
Makes sense.
> 
> Signed-off-by: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
Acked-by: Jonathan Cameron <jic23@xxxxxxxxxx>
> ---
>  drivers/staging/iio/industrialio-core.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
> index 82c9128..6fc1430 100644
> --- a/drivers/staging/iio/industrialio-core.c
> +++ b/drivers/staging/iio/industrialio-core.c
> @@ -800,6 +800,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;
> @@ -828,6 +830,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;

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux