pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-gprs/+/34016 )

Change subject: llc: Fix potential null ptr dereference in LL-Xid.Ind
......................................................................

llc: Fix potential null ptr dereference in LL-Xid.Ind

Closes: Coverity CID#322365
Change-Id: Icc65af3ea9a44a5daf80e47717564f6adf37444b
---
M src/llc/llc_ll.c
1 file changed, 17 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved




diff --git a/src/llc/llc_ll.c b/src/llc/llc_ll.c
index ad87dba..45675c3 100644
--- a/src/llc/llc_ll.c
+++ b/src/llc/llc_ll.c
@@ -172,17 +172,22 @@
                                        const struct gprs_llc_xid_field 
*xid_field_request_l3)
 {
        struct osmo_gprs_llc_prim *llc_prim_tx;
-       llc_prim_tx = gprs_llc_prim_alloc_ll_xid_ind(lle->llme->tlli, 
lle->sapi, NULL, xid_field_request_l3->var.val_len);
-       OSMO_ASSERT(llc_prim_tx);
+
        if (xid_field_request_l3) {
+               llc_prim_tx = gprs_llc_prim_alloc_ll_xid_ind(lle->llme->tlli, 
lle->sapi, NULL, xid_field_request_l3->var.val_len);
+               OSMO_ASSERT(llc_prim_tx);
                llc_prim_tx->ll.l3_pdu_len = xid_field_request_l3->var.val_len;
                llc_prim_tx->ll.l3_pdu = msgb_put(llc_prim_tx->oph.msg, 
llc_prim_tx->ll.l3_pdu_len);
                if (llc_prim_tx->ll.l3_pdu_len > 0)
                        memcpy(llc_prim_tx->ll.l3_pdu, 
xid_field_request_l3->var.val,
                               llc_prim_tx->ll.l3_pdu_len);
+       } else {
+               llc_prim_tx = gprs_llc_prim_alloc_ll_xid_ind(lle->llme->tlli, 
lle->sapi, NULL, 0);
+               OSMO_ASSERT(llc_prim_tx);
        }
        llc_prim_tx->ll.xid.n201_i = lle->params.n201_i;
        llc_prim_tx->ll.xid.n201_u = lle->params.n201_u;
+
        return gprs_llc_prim_call_up_cb(llc_prim_tx);
 }


--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/34016
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: Icc65af3ea9a44a5daf80e47717564f6adf37444b
Gerrit-Change-Number: 34016
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to