neels has uploaded this change for review.

View Change

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(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/16/36416/1
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);

To view, visit change 36416. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I77ddd627ebfe96c7674c6a197af8b2c4b1a4024c
Gerrit-Change-Number: 36416
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr@sysmocom.de>
Gerrit-MessageType: newchange