summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-12-24 17:58:13 +0100
committerHarald Welte <laforge@gnumonks.org>2016-12-24 17:58:13 +0100
commitd2510459a8b5f4ae0ee3740dd36ca1c4abd290b6 (patch)
tree179b0b5a3467a2cbc283934e3cc4ddaf750b9624 /src
parentc68ce3b9fe1314f8133eed1e7246fdfee9295744 (diff)
serial.c: Fix fd leak in case of fcntl() error paths
Change-Id: I14f934957e1086b803f3a7b9b5e6d602380f0be2 Fixes: Coverity CID 158987
Diffstat (limited to 'src')
-rw-r--r--src/serial.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/serial.c b/src/serial.c
index 1cbd3c06..6316e459 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -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 */