Private
Public Access
2
0

iio.c: Check return of fd before using ioctl

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-12-21 15:48:28 +00:00
parent ff34651325
commit e98bd8653a

View File

@@ -443,8 +443,12 @@ mraa_iio_event_poll(mraa_iio_context dev, struct iio_event_data* data)
snprintf(bu, MAX_SIZE, IIO_SLASH_DEV "%d", dev->num);
fd = open(bu, 0);
ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
close(fd);
if (fd != -1) {
ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
close(fd);
} else {
return MRAA_ERROR_UNSPECIFIED;
}
if (ret == -1 || event_fd == -1)
return MRAA_ERROR_UNSPECIFIED;