summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-12-12 16:16:35 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-12-12 16:20:19 +0100
commite18209c975a3f5efcf40178845d1865f0afc67fe (patch)
tree61e4bedb33ba3057a4c57d81a04c0f146cb7cc4a
parent7f180e83c378107e791ceabaf44aa9fc29dd4bfe (diff)
ipa-proxy: Socket creation can fail, address coverity issue
Fixes: Coverity CID 1040722
-rw-r--r--openbsc/src/ipaccess/ipaccess-proxy.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/openbsc/src/ipaccess/ipaccess-proxy.c b/openbsc/src/ipaccess/ipaccess-proxy.c
index 9ab4ebbf4..ae24d1635 100644
--- a/openbsc/src/ipaccess/ipaccess-proxy.c
+++ b/openbsc/src/ipaccess/ipaccess-proxy.c
@@ -1005,6 +1005,13 @@ static struct ipa_proxy_conn *connect_bsc(struct sockaddr_in *sa, int priv_nr, v
bfd->data = ipc;
bfd->priv_nr = priv_nr;
+ if (bfd->fd < 0) {
+ LOGP(DLINP, LOGL_ERROR, "Could not create socket: %s\n",
+ strerror(errno));
+ talloc_free(ipc);
+ return NULL;
+ }
+
setsockopt(bfd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
ret = connect(bfd->fd, (struct sockaddr *) sa, sizeof(*sa));