iio: potentiometer: ds1803: Remove VLA usage
authorHimanshu Jha <himanshujha199640@gmail.com>
Thu, 8 Mar 2018 18:45:33 +0000 (00:15 +0530)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 10 Mar 2018 15:02:41 +0000 (15:02 +0000)
In preparation to enabling -Wvla, remove VLA usage and replace it
with fixed a fixed length array and therefore, prevent potential
stack overflow attacks.

Fixed as a part of the discussion to remove all VLAs from the kernel:
https://lkml.org/lkml/2018/3/7/621

Cc: keescook@chromium.org
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/potentiometer/ds1803.c

index 9b0ff4ab2f9c8b994620db7abf1e03a47f969710..6bf12c9eccbd29a7157a12e327ef38bb2a127edc 100644 (file)
@@ -64,7 +64,7 @@ static int ds1803_read_raw(struct iio_dev *indio_dev,
        struct ds1803_data *data = iio_priv(indio_dev);
        int pot = chan->channel;
        int ret;
-       u8 result[indio_dev->num_channels];
+       u8 result[ARRAY_SIZE(ds1803_channels)];
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW: