[PATCH] libosmocore[master]: serial.c: Fix fd leak in case of fcntl() error paths

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Dec 24 17:00:32 UTC 2016


Review at  https://gerrit.osmocom.org/1502

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

Change-Id: I14f934957e1086b803f3a7b9b5e6d602380f0be2
Fixes: Coverity CID 158987
---
M src/serial.c
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/02/1502/1

diff --git a/src/serial.c b/src/serial.c
index 1cbd3c0..6316e45 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -73,14 +73,16 @@
 	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 */

-- 
To view, visit https://gerrit.osmocom.org/1502
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I14f934957e1086b803f3a7b9b5e6d602380f0be2
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list