From a84db616737cda5dfc6e8590a29523dc08090f60 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 9 Apr 2015 14:22:22 +0200 Subject: gprs: Add assertion for msg != NULL to bssgp_msgb_alloc (Coverity) Currently out-of-memory is not handled by bssgp_msgb_alloc, leading to SEGV failures if msgb_alloc_headroom returns NULL. This commit adds an OSMO_ASSERT to catch this case, which improves the situation only slightly. But bssgp_msgb_alloc is used in many places without checking the return value, so just adding a conditional early NULL return would not fix the issue either. Fixes: Coverity CID 1293377 Sponsored-by: On-Waves ehf --- src/gb/gprs_bssgp_util.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/gb/gprs_bssgp_util.c b/src/gb/gprs_bssgp_util.c index fe66f460..3c42e4d4 100644 --- a/src/gb/gprs_bssgp_util.c +++ b/src/gb/gprs_bssgp_util.c @@ -71,6 +71,10 @@ const char *bssgp_cause_str(enum gprs_bssgp_cause cause) struct msgb *bssgp_msgb_alloc(void) { struct msgb *msg = msgb_alloc_headroom(4096, 128, "BSSGP"); + + /* TODO: Add handling of msg == NULL to this function and to all callers */ + OSMO_ASSERT(msg != NULL); + msgb_bssgph(msg) = msg->data; return msg; } -- cgit v1.2.3