From d19c7590331b7b666e29e7bb2e8f588bef818966 Mon Sep 17 00:00:00 2001 From: Michael West Date: Tue, 29 May 2018 16:41:32 -0700 Subject: x300_impl: Assign Channel Variable Before Err Check --- host/lib/usrp/x300/x300_impl.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'host/lib/usrp') diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 5f5aae403..2627ff1a2 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -1126,15 +1126,16 @@ uint32_t x300_impl::mboard_members_t::allocate_pcie_dma_chan(const uhd::sid_t &t uint32_t raw_sid = tx_sid.get(); if (_dma_chan_pool.count(raw_sid) == 0) { - _dma_chan_pool[raw_sid] = _dma_chan_pool.size() + FIRST_DATA_CHANNEL; + size_t channel = _dma_chan_pool.size() + FIRST_DATA_CHANNEL; + if (channel > X300_PCIE_MAX_CHANNELS) { + throw uhd::runtime_error("Trying to allocate more DMA channels than are available"); + } + _dma_chan_pool[raw_sid] = channel; UHD_LOGGER_DEBUG("X300") << "Assigning PCIe DMA channel " << _dma_chan_pool[raw_sid] << " to SID " << tx_sid.to_pp_string_hex(); } - if (_dma_chan_pool.size() + FIRST_DATA_CHANNEL > X300_PCIE_MAX_CHANNELS) { - throw uhd::runtime_error("Trying to allocate more DMA channels than are available"); - } return _dma_chan_pool[raw_sid]; } } -- cgit v1.2.3