[MERGED] 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:06:47 UTC 2016


Harald Welte has submitted this change and it was merged.

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


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(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: I14f934957e1086b803f3a7b9b5e6d602380f0be2
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list