From: Brendan Le Foll Date: Mon, 21 Dec 2015 15:38:20 +0000 (+0000) Subject: iio.c: Closedir correctly and return error if we fail to read from the device dir X-Git-Tag: v0.9.0~4 X-Git-Url: http://review.tizen.org/git/?p=contrib%2Fmraa.git;a=commitdiff_plain;h=58cf292dfc90340b15052ac86de641b6516badbe iio.c: Closedir correctly and return error if we fail to read from the device dir Signed-off-by: Brendan Le Foll --- diff --git a/src/iio/iio.c b/src/iio/iio.c index 1aee9fe..f15a337 100644 --- a/src/iio/iio.c +++ b/src/iio/iio.c @@ -599,6 +599,8 @@ mraa_iio_update_channels(mraa_iio_context dev) if (read(fd, readbuf, 2 * sizeof(char)) != 2) { syslog(LOG_ERR, "iio: Failed to read a sensible value from sysfs"); free(str); + close(fd); + closedir(dir); return -1; } chan->enabled = (int) strtol(readbuf, NULL, 10); @@ -617,8 +619,11 @@ mraa_iio_update_channels(mraa_iio_context dev) } } } + closedir(dir); + return MRAA_SUCCESS; } - return MRAA_SUCCESS; + + return MRAA_ERROR_INVALID_HANDLE; } mraa_result_t