From d154f8bda2e379a8a0e1c3712a9af6a9d97b7b97 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 9 Apr 2015 14:22:21 +0200 Subject: msgb: Check the return value of msgb_alloc (Coverity) In some places, the return value of msgb_alloc/msgb_alloc_headroom is not checked before it is dereferenced. This commit adds NULL checks to return with -ENOMEM from the calling functions if the alloc function has failed. Fixes: Coverity CID 1249692, 1293376 Sponsored-by: On-Waves ehf --- src/gsm/lapdm.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gsm') diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c index 698f8502..54d3a0b8 100644 --- a/src/gsm/lapdm.c +++ b/src/gsm/lapdm.c @@ -675,6 +675,9 @@ static int l2_ph_rach_ind(struct lapdm_entity *le, uint8_t ra, uint32_t fn, uint struct gsm_time gt; struct msgb *msg = msgb_alloc_headroom(512, 64, "RSL CHAN RQD"); + if (!msg) + return -ENOMEM; + msg->l2h = msgb_push(msg, sizeof(*ch)); ch = (struct abis_rsl_cchan_hdr *)msg->l2h; rsl_init_cchan_hdr(ch, RSL_MT_CHAN_RQD); -- cgit v1.2.3