Review at  https://gerrit.osmocom.org/3110

sccp_sap_up(): guard against NULL pointers

Change-Id: Icd64b92b00461cace5c476c8bcf69eec3fdbbdd3
---
M src/hnbgw_cn.c
1 file changed, 16 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/10/3110/1

diff --git a/src/hnbgw_cn.c b/src/hnbgw_cn.c
index 2fd9d71..8124ce5 100644
--- a/src/hnbgw_cn.c
+++ b/src/hnbgw_cn.c
@@ -327,12 +327,27 @@
 static int sccp_sap_up(struct osmo_prim_hdr *oph, void *ctx)
 {
        struct osmo_sccp_user *scu = ctx;
-       struct hnbgw_cnlink *cnlink = osmo_sccp_user_get_priv(scu);
+       struct hnbgw_cnlink *cnlink;
        struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph;
        int rc;
 
        LOGP(DMAIN, LOGL_DEBUG, "sccp_sap_up(%s)\n", osmo_scu_prim_name(oph));
 
+       if (!scu) {
+               LOGP(DMAIN, LOGL_ERROR,
+                    "sccp_sap_up(): NULL osmo_sccp_user, cannot send prim (sap 
%u prim %u op %d)\n",
+                    oph->sap, oph->primitive, oph->operation);
+               return -1;
+       }
+
+       cnlink = osmo_sccp_user_get_priv(scu);
+       if (!cnlink) {
+               LOGP(DMAIN, LOGL_ERROR,
+                    "sccp_sap_up(): NULL hnbgw_cnlink, cannot send prim (sap 
%u prim %u op %d)\n",
+                    oph->sap, oph->primitive, oph->operation);
+               return -1;
+       }
+
        switch (OSMO_PRIM_HDR(oph)) {
        case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION):
                rc = handle_cn_unitdata(cnlink, &prim->u.unitdata, oph);

-- 
To view, visit https://gerrit.osmocom.org/3110
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd64b92b00461cace5c476c8bcf69eec3fdbbdd3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>

Reply via email to