From 272f296cd349423af4b473526ef93ba59fc243a3 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 17 Dec 2021 13:45:34 +0100 Subject: [PATCH] gtp: Fix possible null pointer dereference Closes: Coverity CID#242771 Change-Id: I412082cc5fa93818d321210c34a2d22c038cb985 --- src/osmo-hnodeb/gtp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/osmo-hnodeb/gtp.c b/src/osmo-hnodeb/gtp.c index 22d4074..f7d9a14 100644 --- a/src/osmo-hnodeb/gtp.c +++ b/src/osmo-hnodeb/gtp.c @@ -79,12 +79,18 @@ static int hnb_gtp_cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len struct hnb *hnb; int rc; - if (!conn || !conn->ue->conn_ps.active) { - LOGUE(conn->ue, DGTP, LOGL_NOTICE, "Tx GTP-CONN_DATA.ind data=%p len=%u but UE conn_ps is not active!\n", - packet, len); + if (!conn) { + LOGP(DGTP, LOGL_NOTICE, "Tx GTP-CONN_DATA.ind data=%p len=%u with no conn!\n", + packet, len); return -EINVAL; } ue = conn->ue; + + if (!ue->conn_ps.active) { + LOGUE(ue, DGTP, LOGL_NOTICE, "Tx GTP-CONN_DATA.ind data=%p len=%u but UE conn_ps is not active!\n", + packet, len); + return -EINVAL; + } hnb = ue->hnb; LOGUE(ue, DGTP, LOGL_DEBUG, "Tx GTP-CONN_DATA.ind data=%p len=%u\n", packet, len);