From 1b624ba1f6ecd31be9170b36d0747c0fc5d1e887 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 14 Jul 2013 08:59:32 +0200 Subject: smpp: Close the file descriptor when we can't accept the SMSC conn When we failed to allocate the memory or failed to register the fd we would have leaked the file descriptor. Close the fd and avoid the leak. --- openbsc/src/libmsc/smpp_smsc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openbsc/src/libmsc/smpp_smsc.c b/openbsc/src/libmsc/smpp_smsc.c index 2b17d1230..1dc37fdd8 100644 --- a/openbsc/src/libmsc/smpp_smsc.c +++ b/openbsc/src/libmsc/smpp_smsc.c @@ -867,8 +867,10 @@ static int link_accept_cb(struct smsc *smsc, int fd, struct sockaddr_storage *s, socklen_t s_len) { struct osmo_esme *esme = talloc_zero(smsc, struct osmo_esme); - if (!esme) + if (!esme) { + close(fd); return -ENOMEM; + } smpp_esme_get(esme); esme->own_seq_nr = rand(); @@ -880,6 +882,7 @@ static int link_accept_cb(struct smsc *smsc, int fd, esme->wqueue.bfd.when = BSC_FD_READ; if (osmo_fd_register(&esme->wqueue.bfd) != 0) { + close(fd); talloc_free(esme); return -EIO; } -- cgit v1.2.3