serial.c: Fix fd leak in case of fcntl() error paths

Change-Id: I14f934957e1086b803f3a7b9b5e6d602380f0be2
Fixes: Coverity CID 158987
This commit is contained in:
Harald Welte 2016-12-24 17:58:13 +01:00
parent c68ce3b9fe
commit d2510459a8
1 changed files with 4 additions and 2 deletions

View File

@ -73,14 +73,16 @@ osmo_serial_init(const char *dev, speed_t baudrate)
flags = fcntl(fd, F_GETFL, 0);
if (flags < 0) {
dbg_perror("fcntl get flags");
return -1;
rc = -errno;
goto error;
}
flags &= ~O_NONBLOCK;
rc = fcntl(fd, F_SETFL, flags);
if (rc != 0) {
dbg_perror("fcntl set flags");
return -1;
rc = -errno;
goto error;
}
/* Configure serial interface */