From f653821fb30f511be6cb775403ae3a5fc9e8ccd6 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Wed, 10 Oct 2018 16:09:32 +0200 Subject: fix error handling gprs_ns_nsip_listen() If we cannot bind the listening socket, reset related fields in the osmo fd structure to NULL again. Otherwise our caller might eventually try to use an uninitialized osmo fd. Change-Id: Ia953b2eff54cac0bd980944291f75db14df09a34 Related: OS#3643 --- src/gb/gprs_ns.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 9b7cc056..198ead19 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -1628,8 +1628,11 @@ int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi) LOGP(DNS, LOGL_NOTICE, "Listening for nsip packets on %s:%u\n", inet_ntoa(in), nsi->nsip.local_port); } - if (ret < 0) + if (ret < 0) { + nsi->nsip.fd.cb = NULL; + nsi->nsip.fd.data = NULL; return ret; + } ret = setsockopt(nsi->nsip.fd.fd, IPPROTO_IP, IP_TOS, &nsi->nsip.dscp, sizeof(nsi->nsip.dscp)); -- cgit v1.2.3