[PATCH] libosmocore[master]: Fix unchecked return valueof osmo_fd_register()

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
Fri Nov 25 23:12:50 UTC 2016


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

Fix unchecked return valueof osmo_fd_register()

Change-Id: Ib040a7f94eb1bbec8270b66fd4c2aedef9d5346a
Fixes: Coverity CID 57636
---
M src/gsmtap_util.c
1 file changed, 12 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/82/1282/1

diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 7a63771..66abdf1 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -333,7 +333,7 @@
  */
 int gsmtap_source_add_sink(struct gsmtap_inst *gti)
 {
-	int fd;
+	int fd, rc;
 
 	fd = gsmtap_source_add_sink_fd(gsmtap_inst_fd(gti));
 	if (fd < 0)
@@ -347,7 +347,11 @@
 		sink_ofd->when = BSC_FD_READ;
 		sink_ofd->cb = gsmtap_sink_fd_cb;
 
-		osmo_fd_register(sink_ofd);
+		rc = osmo_fd_register(sink_ofd);
+		if (rc < 0) {
+			close(fd);
+			return rc;
+		}
 	}
 
 	return fd;
@@ -368,7 +372,7 @@
 					int ofd_wq_mode)
 {
 	struct gsmtap_inst *gti;
-	int fd;
+	int fd, rc;
 
 	fd = gsmtap_source_init_fd(host, port);
 	if (fd < 0)
@@ -383,7 +387,11 @@
 		osmo_wqueue_init(&gti->wq, 64);
 		gti->wq.write_cb = &gsmtap_wq_w_cb;
 
-		osmo_fd_register(&gti->wq.bfd);
+		rc = osmo_fd_register(&gti->wq.bfd);
+		if (rc < 0) {
+			close(fd);
+			return NULL;
+		}
 	}
 
 	return gti;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib040a7f94eb1bbec8270b66fd4c2aedef9d5346a
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