neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/36416?usp=email )
Change subject: fix null deref on hnb_context_release ......................................................................
fix null deref on hnb_context_release
Usually, a hnb_context still has a hnb_persistent associated at release time. But that is not guaranteed.
See also further below, where the function tests for ctx->persistent correctly.
Change-Id: I77ddd627ebfe96c7674c6a197af8b2c4b1a4024c --- M src/osmo-hnbgw/hnbgw.c 1 file changed, 21 insertions(+), 4 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c index fff900a..64bb66f 100644 --- a/src/osmo-hnbgw/hnbgw.c +++ b/src/osmo-hnbgw/hnbgw.c @@ -310,13 +310,15 @@ void hnb_context_release(struct hnb_context *ctx) { struct hnbgw_context_map *map; - struct timespec tp; - int rc;
LOGHNB(ctx, DMAIN, LOGL_INFO, "Releasing HNB context\n");
- rc = osmo_clock_gettime(CLOCK_MONOTONIC, &tp); - ctx->persistent->updowntime = (rc < 0) ? 0 : tp.tv_sec; + if (ctx->persistent) { + struct timespec tp; + int rc; + rc = osmo_clock_gettime(CLOCK_MONOTONIC, &tp); + ctx->persistent->updowntime = (rc < 0) ? 0 : tp.tv_sec; + }
/* remove from the list of HNB contexts */ llist_del(&ctx->list);