From 9d862c89989e5841a2242ed0cde0e6fa0f4a6d2e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 26 Nov 2016 00:10:07 +0100 Subject: Fix unchecked return valueof osmo_fd_register() Change-Id: Ib040a7f94eb1bbec8270b66fd4c2aedef9d5346a Fixes: Coverity CID 57636 --- src/gsmtap_util.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c index 7a63771a..66abdf17 100644 --- a/src/gsmtap_util.c +++ b/src/gsmtap_util.c @@ -333,7 +333,7 @@ static int gsmtap_sink_fd_cb(struct osmo_fd *fd, unsigned int flags) */ 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 @@ int gsmtap_source_add_sink(struct gsmtap_inst *gti) 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 @@ struct gsmtap_inst *gsmtap_source_init(const char *host, uint16_t port, 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 @@ struct gsmtap_inst *gsmtap_source_init(const char *host, uint16_t port, osmo_wqueue_init(>i->wq, 64); gti->wq.write_cb = &gsmtap_wq_w_cb; - osmo_fd_register(>i->wq.bfd); + rc = osmo_fd_register(>i->wq.bfd); + if (rc < 0) { + close(fd); + return NULL; + } } return gti; -- cgit v1.2.3