Private
Public Access
2
0

iio: Check fd against != -1 and not > 0 and avoid leaks during error handling

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-12-21 15:15:15 +00:00
parent ee69045ea8
commit f4385a8b82
2 changed files with 13 additions and 7 deletions

View File

@@ -220,7 +220,7 @@ mraa_iio_detect()
device->num = i;
snprintf(filepath, 64, "/sys/bus/iio/devices/iio:device%d/name", i);
fd = open(filepath, O_RDONLY);
if (fd > 0) {
if (fd != -1) {
len = read(fd, &name, 64);
if (len > 1) {
// remove any trailing CR/LF symbols