Re: [PATCH] iio: core: check 'info' value before registering the device

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

 



On Sun,  2 Dec 2018 20:30:31 +0200
Andi Shyti <andi@xxxxxxxxxxx> wrote:

> When the 'info' structure inside indio_dev is left uninitialized,
> a segmentation fault occurs.
> 
> Check the 'info' value before using it and if it is equal to
> NULL, return with -EINVAL.
> 
> Signed-off-by: Andi Shyti <andi@xxxxxxxxxxx>

Hmm. It would be an impressive level of bug if that one got through
in a driver but paranoia does no harm I suppose.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/industrialio-core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index a062cfddc5af..4f5cd9f60870 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1671,6 +1671,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!indio_dev->info)
> +		return -EINVAL;
> +
>  	/* configure elements for the chrdev */
>  	indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
>  




[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