OSDN Git Service

iio: core: check 'info' value before registering the device
authorAndi Shyti <andi@etezian.org>
Sun, 2 Dec 2018 18:30:31 +0000 (20:30 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 8 Dec 2018 11:06:41 +0000 (11:06 +0000)
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>
drivers/iio/industrialio-core.c

index a062cfd..4f5cd9f 100644 (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);