Change in libosmo-abis[master]: ipa: Make ipa_server_conn_destroy() re-entrant

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Mar 8 15:36:09 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13195


Change subject: ipa: Make ipa_server_conn_destroy() re-entrant
......................................................................

ipa: Make ipa_server_conn_destroy() re-entrant

In some situations, the user code called by the closed_cb call-back
might be tempted to call itself ipa_server_conn_destroy(), which would lead
to a double-llist_del during osmo_fd_unregister() and also a subsequent
double talloc_free().  Let's prevent such misuse by existing early in
such situations.

Change-Id: I0fef264ed5b4218906cdbca243ffa11b891025c6
---
M src/input/ipa.c
1 file changed, 5 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/95/13195/1

diff --git a/src/input/ipa.c b/src/input/ipa.c
index e41ec42..25eeb4a 100644
--- a/src/input/ipa.c
+++ b/src/input/ipa.c
@@ -503,7 +503,12 @@
 
 void ipa_server_conn_destroy(struct ipa_server_conn *conn)
 {
+	/* make the function re-entrant in case closed_cb() below somehow
+	 * calls again into this destructor */
+	if (conn->ofd.fd == -1)
+		return;
 	close(conn->ofd.fd);
+	conn->ofd.fd = -1;
 	msgb_free(conn->pending_msg);
 	osmo_fd_unregister(&conn->ofd);
 	if (conn->closed_cb)

-- 
To view, visit https://gerrit.osmocom.org/13195
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0fef264ed5b4218906cdbca243ffa11b891025c6
Gerrit-Change-Number: 13195
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190308/d8194d61/attachment.htm>


More information about the gerrit-log mailing list