diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-07-14 08:59:32 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-07-14 09:04:51 +0200 |
commit | 1b624ba1f6ecd31be9170b36d0747c0fc5d1e887 (patch) | |
tree | 701b380bce02d647d9e0d01b5df1a3444e96693b /openbsc/src | |
parent | c962d45669ca5003952d36c6c0c94167f5b2f504 (diff) |
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.
Diffstat (limited to 'openbsc/src')
-rw-r--r-- | openbsc/src/libmsc/smpp_smsc.c | 5 |
1 files changed, 4 insertions, 1 deletions
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; } |