Commit d45ebf1f authored by Andi Shyti's avatar Andi Shyti Committed by Jonathan Cameron

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: default avatarAndi Shyti <andi@etezian.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 794e20ee
...@@ -1671,6 +1671,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) ...@@ -1671,6 +1671,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
if (ret < 0) if (ret < 0)
return ret; return ret;
if (!indio_dev->info)
return -EINVAL;
/* configure elements for the chrdev */ /* configure elements for the chrdev */
indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id); indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment