From patchwork Sun May 22 11:51:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gerrit-no-reply@lists.osmocom.org X-Patchwork-Id: 624948 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 3rCKkz3FHPz9t3p for ; Sun, 22 May 2016 21:51:23 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 31B0A696F; Sun, 22 May 2016 11:51:20 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from 127.0.1.12 (unknown [127.0.1.12]) by lists.osmocom.org (Postfix) with ESMTPA id 894786961; Sun, 22 May 2016 11:51:18 +0000 (UTC) Date: Sun, 22 May 2016 11:51:18 +0000 From: Neels Hofmeyr To: Harald Welte X-Gerrit-MessageType: merged Subject: [MERGED] openbsc[master]: subscr_name(): Handle case for subscr == NULL X-Gerrit-Change-Id: Ide09f4a515222eb2ec6c25e7a6a8c5f6cc2ffd4b X-Gerrit-ChangeURL: X-Gerrit-Commit: 7184bd088e11cfe6b907af2fcce48369fd2f21f1 In-Reply-To: References: MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/2.12.2-31-gb331dbd-dirty X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: nhofmeyr@sysmocom.de Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Message-Id: <20160522115120.31B0A696F@lists.osmocom.org> Neels Hofmeyr has submitted this change and it was merged. Change subject: subscr_name(): Handle case for subscr == NULL ...................................................................... subscr_name(): Handle case for subscr == NULL subscr_name() was called from several places: * either without a check for subscr being NULL, which for example was causing a segfault if we hand-over a channel before identifying the subscriber * or with an explicit NULL check and the ternary operator (?). We now simplify the code by checking for the NULL Subscriber in subscr_name() itself. Change-Id: Ide09f4a515222eb2ec6c25e7a6a8c5f6cc2ffd4b Reviewed-on: https://gerrit.osmocom.org/92 Tested-by: Jenkins Builder Reviewed-by: Holger Freyther --- M openbsc/src/libbsc/abis_rsl.c M openbsc/src/libcommon/gsm_subscriber_base.c M openbsc/src/libmsc/gsm_04_08.c 3 files changed, 6 insertions(+), 6 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 6cf4e0b..c3a0c5c 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -1051,7 +1051,7 @@ int i; char *name = ""; - if (lchan && lchan->conn && lchan->conn->subscr) + if (lchan && lchan->conn) name = subscr_name(lchan->conn->subscr); DEBUGP(DMEAS, "[%s] MEASUREMENT RESULT NR=%d ", name, mr->nr); diff --git a/openbsc/src/libcommon/gsm_subscriber_base.c b/openbsc/src/libcommon/gsm_subscriber_base.c index 50f4118..1f98cc6 100644 --- a/openbsc/src/libcommon/gsm_subscriber_base.c +++ b/openbsc/src/libcommon/gsm_subscriber_base.c @@ -43,6 +43,9 @@ char *subscr_name(struct gsm_subscriber *subscr) { + if (!subscr) + return "unknown"; + if (strlen(subscr->name)) return subscr->name; diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 0f00db1..68cc906 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -447,8 +447,7 @@ msg->lchan = conn->lchan; LOGP(DMM, LOGL_INFO, "Subscriber %s: LOCATION UPDATING REJECT " - "LAC=%u BTS=%u\n", conn->subscr ? - subscr_name(conn->subscr) : "unknown", + "LAC=%u BTS=%u\n", subscr_name(conn->subscr), bts->location_area_code, bts->nr); return gsm48_conn_sendmsg(msg, conn, NULL); @@ -1153,9 +1152,7 @@ break; case GSM48_MT_MM_TMSI_REALL_COMPL: DEBUGP(DMM, "TMSI Reallocation Completed. Subscriber: %s\n", - conn->subscr ? - subscr_name(conn->subscr) : - "unknown subscriber"); + subscr_name(conn->subscr)); release_loc_updating_req(conn, 1); break; case GSM48_MT_MM_IMSI_DETACH_IND: