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

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Mar 11 13:15:35 UTC 2019


Harald Welte has submitted this change and it was merged. ( 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(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Max: Looks good to me, approved



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: merged
Gerrit-Change-Id: I0fef264ed5b4218906cdbca243ffa11b891025c6
Gerrit-Change-Number: 13195
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190311/d1fc8de1/attachment.html>


More information about the gerrit-log mailing list