mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-10-23 08:12:01 +00:00
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.
This commit is contained in:
@@ -867,8 +867,10 @@ static int link_accept_cb(struct smsc *smsc, int fd,
|
|||||||
struct sockaddr_storage *s, socklen_t s_len)
|
struct sockaddr_storage *s, socklen_t s_len)
|
||||||
{
|
{
|
||||||
struct osmo_esme *esme = talloc_zero(smsc, struct osmo_esme);
|
struct osmo_esme *esme = talloc_zero(smsc, struct osmo_esme);
|
||||||
if (!esme)
|
if (!esme) {
|
||||||
|
close(fd);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
smpp_esme_get(esme);
|
smpp_esme_get(esme);
|
||||||
esme->own_seq_nr = rand();
|
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;
|
esme->wqueue.bfd.when = BSC_FD_READ;
|
||||||
|
|
||||||
if (osmo_fd_register(&esme->wqueue.bfd) != 0) {
|
if (osmo_fd_register(&esme->wqueue.bfd) != 0) {
|
||||||
|
close(fd);
|
||||||
talloc_free(esme);
|
talloc_free(esme);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user