From 721574b6753e133dea981587f6f09ab7ef9c26a1 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Sat, 9 May 2020 08:04:47 +0200 Subject: om2k: Fix invalid use of linked list when building hopping freq list I originally assumed that after a complete scan with llist_for_each_entry the loop counter would be either NULL or a valid entry. That's just not the case. Fixes: CID#210256 Signed-off-by: Sylvain Munaut Change-Id: Iad647b74771c4ac406a88effd371ed7748c8847e --- src/osmo-bsc/abis_om2000.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/osmo-bsc/abis_om2000.c b/src/osmo-bsc/abis_om2000.c index c69655732..0aea684c0 100644 --- a/src/osmo-bsc/abis_om2000.c +++ b/src/osmo-bsc/abis_om2000.c @@ -1452,14 +1452,16 @@ static uint8_t ts2comb(struct gsm_bts_trx_ts *ts) static int put_freq_list(uint8_t *buf, struct gsm_bts_trx_ts *ts, uint16_t arfcn) { - struct gsm_bts_trx *trx; + struct gsm_bts_trx *t, *trx = NULL; /* Find the TRX that's configured for that ARFCN */ - llist_for_each_entry(trx, &ts->trx->bts->trx_list, list) - if (trx->arfcn == arfcn) + llist_for_each_entry(t, &ts->trx->bts->trx_list, list) + if (t->arfcn == arfcn) { + trx = t; break; + } - if (!trx || (trx->arfcn != arfcn)) { + if (!trx) { LOGP(DNM, LOGL_ERROR, "Trying to use ARFCN %d for hopping with no TRX configured for it", arfcn); return 0; } -- cgit v1.2.3