From d0ef1ed78cc4e8e04296342499991fdde77fbbe7 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Mon, 23 Jan 2017 15:36:37 +0100 Subject: [PATCH] compression: Fix nullpointer deref When the creation of a new compression entity fails, an error message is created, this error message contains printf with a dereferentiation of the compression entity, that is clearly NULL at that point. This commit corrects that. Change-Id: I87371ade0ccd6a93b446f2013c1747f486739518 --- openbsc/src/gprs/gprs_sndcp_comp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openbsc/src/gprs/gprs_sndcp_comp.c b/openbsc/src/gprs/gprs_sndcp_comp.c index 1591f803c..a12c39aa6 100644 --- a/openbsc/src/gprs/gprs_sndcp_comp.c +++ b/openbsc/src/gprs/gprs_sndcp_comp.c @@ -107,13 +107,14 @@ static struct gprs_sndcp_comp *gprs_sndcp_comp_create(const void *ctx, } } - /* Display info message */ + /* Bail on failure */ if (comp_entity == NULL) { LOGP(DSNDCP, LOGL_ERROR, - "Compression entity (%d) creation failed!\n", - comp_entity->entity); + "Compression entity creation failed!\n"); return NULL; } + + /* Display info message */ if (comp_entity->compclass == SNDCP_XID_PROTOCOL_COMPRESSION) { LOGP(DSNDCP, LOGL_INFO, "New header compression entity (%d) created.\n",