diff --git a/src/iio/iio.c b/src/iio/iio.c index 80184cc..2514c8c 100644 --- a/src/iio/iio.c +++ b/src/iio/iio.c @@ -175,7 +175,14 @@ mraa_iio_get_channel_data(mraa_iio_context dev) // channel location has to be done in channel index order so do it afetr we // have grabbed all the correct info for (i = 0; i < dev->chan_num; i++) { - chan = &dev->channels[i]; + chan = &dev->channels[i]; + + if(chan->bytes <= 0) + { + syslog(LOG_ERR, "iio: Channel %d with channel bytes value <= 0"); + return MRAA_IO_SETUP_FAILURE; + } + if (curr_bytes % chan->bytes == 0) { chan->location = curr_bytes; } else {