aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2013-06-30 14:21:54 +0200
committerHarald Welte <laforge@gnumonks.org>2013-10-06 11:54:38 +0200
commite68055bf112c62a5134c6f88f8384967515fb884 (patch)
treedc223dfd4858fcdccf31c70d70218e091fe8cfa4
parent10b41306dbddd6e2cdb182e33f1f1be03152375d (diff)
ipa: protect against multiple subsequent calls to ipa_client_conn_close()
This would create linked list coruption in osmo_fd_unregister(). The fact that multiple calls of osmo_fd_unrgeister() on the same fd happen is due to the fact that ipaccess_drop() and others already close the file descriptor.
-rw-r--r--src/input/ipa.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/input/ipa.c b/src/input/ipa.c
index 0a1172f..8c6f603 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -108,8 +108,12 @@ static void ipa_client_retry(struct ipa_client_conn *link)
void ipa_client_conn_close(struct ipa_client_conn *link)
{
- osmo_fd_unregister(link->ofd);
- close(link->ofd->fd);
+ /* be safe against multiple calls */
+ if (link->ofd->fd != -1) {
+ osmo_fd_unregister(link->ofd);
+ close(link->ofd->fd);
+ link->ofd->fd = -1;
+ }
}
static void ipa_client_read(struct ipa_client_conn *link)