1
0
Fork 0

iio: core: check 'info' value before registering the device

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@etezian.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
hifive-unleashed-5.1
Andi Shyti 2018-12-02 20:30:31 +02:00 committed by Jonathan Cameron
parent 794e20ee03
commit d45ebf1f98
1 changed files with 3 additions and 0 deletions

View File

@ -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);