Skip to content

Commit

Permalink
iio: core: check 'info' value before registering the device
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andi Shyti authored and commodo committed Mar 24, 2020
1 parent 4e7d0e8 commit f91ea47
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,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);

Expand Down

0 comments on commit f91ea47

Please sign in to comment.