mirror of https://gerrit.osmocom.org/libosmocore
serial.c: Fix fd leak in case of fcntl() error paths
Change-Id: I14f934957e1086b803f3a7b9b5e6d602380f0be2 Fixes: Coverity CID 158987
This commit is contained in:
parent
c68ce3b9fe
commit
d2510459a8
|
@ -73,14 +73,16 @@ osmo_serial_init(const char *dev, speed_t baudrate)
|
||||||
flags = fcntl(fd, F_GETFL, 0);
|
flags = fcntl(fd, F_GETFL, 0);
|
||||||
if (flags < 0) {
|
if (flags < 0) {
|
||||||
dbg_perror("fcntl get flags");
|
dbg_perror("fcntl get flags");
|
||||||
return -1;
|
rc = -errno;
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags &= ~O_NONBLOCK;
|
flags &= ~O_NONBLOCK;
|
||||||
rc = fcntl(fd, F_SETFL, flags);
|
rc = fcntl(fd, F_SETFL, flags);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
dbg_perror("fcntl set flags");
|
dbg_perror("fcntl set flags");
|
||||||
return -1;
|
rc = -errno;
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure serial interface */
|
/* Configure serial interface */
|
||||||
|
|
Loading…
Reference in New Issue