From d45ebf1f986db608e0c7d69e8792ee85c9b7f3f4 Mon Sep 17 00:00:00 2001 From: Andi Shyti Date: Sun, 2 Dec 2018 20:30:31 +0200 Subject: [PATCH] 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 Signed-off-by: Jonathan Cameron --- 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); -- 2.30.2