Review at  https://gerrit.osmocom.org/4687

trx: Don't assume phy_instance_by_num() returns non-NULL

In trx_clk_read_cb(), when calling phy_instance_by_num(), that
function might in error cases return a NULL phy-instance. Let's
put an OSMO_ASSERT() there as safeguard to avoid NULL dereference
when dereferencing pinst->trx->bts.

Fixes: Coverity CID#178657
Change-Id: If6b6b45380368e9ee9e03ca1eb7ac56c21e72b03
---
M src/osmo-bts-trx/trx_if.c
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/87/4687/1

diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 1332854..7030e3c 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -103,6 +103,8 @@
        int len;
        uint32_t fn;
 
+       OSMO_ASSERT(pinst);
+
        len = recv(ofd->fd, buf, sizeof(buf) - 1, 0);
        if (len <= 0)
                return len;

-- 
To view, visit https://gerrit.osmocom.org/4687
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If6b6b45380368e9ee9e03ca1eb7ac56c21e72b03
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>

Reply via email to