From patchwork Tue Mar 22 14:40:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max X-Patchwork-Id: 600847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 3qTwNd3RjYz9s4x for ; Wed, 23 Mar 2016 01:40:49 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 1A38D1C1F2; Tue, 22 Mar 2016 14:40:48 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from mail.sysmocom.de (mail.sysmocom.de [IPv6:2a01:4f8:191:444c::2:4]) by lists.osmocom.org (Postfix) with ESMTP id C7A501C1EB for ; Tue, 22 Mar 2016 14:40:46 +0000 (UTC) Received: from mail.sysmocom.de (mail.sysmocom.de [144.76.43.93]) by mail.sysmocom.de (Postfix) with ESMTP id A2ABB18896A; Tue, 22 Mar 2016 14:40:16 +0000 (UTC) Received: from pbell.local (ip5b418565.dynamic.kabel-deutschland.de [91.65.133.101]) by mail.sysmocom.de (Postfix) with ESMTPSA id 67DF9188969; Tue, 22 Mar 2016 14:40:16 +0000 (UTC) From: msuraev@sysmocom.de To: openbsc@lists.osmocom.org Subject: [PATCH 3/5] LC15: fix segfault Date: Tue, 22 Mar 2016 15:40:10 +0100 Message-Id: <1458657612-12669-3-git-send-email-msuraev@sysmocom.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> References: <1458657612-12669-1-git-send-email-msuraev@sysmocom.de> X-Virus-Scanned: ClamAV using ClamSMTP 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: , Cc: Max Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Max Add null pointer check and propagate error. --- include/osmo-bts/phy_link.h | 5 ++++- src/osmo-bts-litecell15/l1_if.c | 6 ++++++ src/osmo-bts-litecell15/l1_if.h | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index a559aa3..5ab5d49 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -125,7 +125,10 @@ void phy_user_statechg_notif(struct phy_instance *pinst, enum phy_link_state lin static inline struct phy_instance *trx_phy_instance(struct gsm_bts_trx *trx) { - return trx->role_bts.l1h; + if (trx) + return trx->role_bts.l1h; + + return NULL; } int bts_model_phy_link_open(struct phy_link *plink); diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index f625968..d89cc29 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -1242,6 +1242,12 @@ static int reset_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp, Litecell15_Prim_t *sysp = msgb_sysprim(resp); GsmL1_Status_t status = sysp->u.layer1ResetCnf.status; + if (!fl1h) { + LOGP(DL1C, LOGL_ERROR, "reset_compl_cb() is unable to get fl1h" + " from trx\n"); + return 1; + } + LOGP(DL1C, LOGL_NOTICE, "Rx L1-RESET.conf (status=%s)\n", get_value_string(lc15bts_l1status_names, status)); diff --git a/src/osmo-bts-litecell15/l1_if.h b/src/osmo-bts-litecell15/l1_if.h index 0c8843b..773840d 100644 --- a/src/osmo-bts-litecell15/l1_if.h +++ b/src/osmo-bts-litecell15/l1_if.h @@ -117,8 +117,10 @@ int l1if_ms_pwr_ctrl(struct gsm_lchan *lchan, const int uplink_target, static inline struct lc15l1_hdl *trx_lc15l1_hdl(struct gsm_bts_trx *trx) { struct phy_instance *pinst = trx_phy_instance(trx); - OSMO_ASSERT(pinst); - return pinst->u.lc15.hdl; + if (pinst) + return pinst->u.lc15.hdl; + + return NULL; } static inline struct gsm_bts_trx *lc15l1_hdl_trx(struct lc15l1_hdl *fl1h)