diff options
author | Andi Shyti <andi@etezian.org> | 2018-12-02 20:30:31 +0200 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2018-12-08 11:06:41 +0000 |
commit | d45ebf1f986db608e0c7d69e8792ee85c9b7f3f4 (patch) | |
tree | b63473d6d3d84245e4b77f235a7fd542e8156fbd /drivers/iio/industrialio-core.c | |
parent | 794e20ee038ea368f3f099d196792b024fb3170c (diff) | |
download | linux-d45ebf1f986db608e0c7d69e8792ee85c9b7f3f4.tar.gz linux-d45ebf1f986db608e0c7d69e8792ee85c9b7f3f4.tar.bz2 linux-d45ebf1f986db608e0c7d69e8792ee85c9b7f3f4.zip |
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>
Diffstat (limited to 'drivers/iio/industrialio-core.c')
-rw-r--r-- | drivers/iio/industrialio-core.c | 3 |
1 files changed, 3 insertions, 0 deletions
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); |