diff options
-rw-r--r-- | host/lib/usrp/x300/x300_impl.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
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]; } } |