From 3dd928ab3b0efbb3eafc324848cdf9ce9f02fd97 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Tue, 27 Oct 2026 23:41:47 -0400 Subject: [PATCH] plugins/samplemimo/plutosdrmimo: Guard against null PlutoSDR device Fix Coverity CID 652457 by checking that `plutoBox` is non-null before calling `setFIR()`. Also guard parameter updates and device queries against a missing PlutoSDR box at the same time. Signed-off-by: Robin Getz --- .../samplemimo/plutosdrmimo/plutosdrmimo.cpp | 89 +++++++------------ 1 file changed, 30 insertions(+), 59 deletions(-) diff --git a/plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp b/plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp index 2094f710c..3156ecb49 100644 --- a/plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp +++ b/plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp @@ -680,11 +680,11 @@ bool PlutoSDRMIMO::applySettings(const PlutoSDRMIMOSettings& settings, const QLi // Tx // Change affecting device sample rate chain and other buddies - if (settingsKeys.contains("devSampleRate") || + if (plutoBox && (settingsKeys.contains("devSampleRate") || settingsKeys.contains("lpfTxFIREnable") || settingsKeys.contains("lpfTxFIRlog2Interp") || settingsKeys.contains("lpfTxFIRBW") || - settingsKeys.contains("lpfTxFIRGain") || force) + settingsKeys.contains("lpfTxFIRGain") || force)) { plutoBox->setFIR( settings.m_devSampleRate, @@ -779,7 +779,7 @@ bool PlutoSDRMIMO::applySettings(const PlutoSDRMIMOSettings& settings, const QLi paramsToSet = true; } - if (paramsToSet) { + if (plutoBox && paramsToSet) { plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params); } @@ -1343,13 +1343,9 @@ void PlutoSDRMIMO::getRxRSSI(std::string& rssiStr, int chan) return; } - if (m_plutoParams) - { - DevicePlutoSDRBox *plutoBox = m_plutoParams->getBox(); - - if (!plutoBox->getRxRSSI(rssiStr, chan)) { - rssiStr = "xxx dB"; - } + DevicePlutoSDRBox *plutoBox = m_plutoParams ? m_plutoParams->getBox() : nullptr; + if (plutoBox && !plutoBox->getRxRSSI(rssiStr, chan)) { + rssiStr = "xxx dB"; } } @@ -1361,15 +1357,10 @@ void PlutoSDRMIMO::getTxRSSI(std::string& rssiStr, int chan) return; } - if (m_plutoParams) - { - DevicePlutoSDRBox *plutoBox = m_plutoParams->getBox(); - - if (!plutoBox->getTxRSSI(rssiStr, chan)) { - rssiStr = "xxx dB"; - } + DevicePlutoSDRBox *plutoBox = m_plutoParams ? m_plutoParams->getBox() : nullptr; + if (plutoBox && !plutoBox->getTxRSSI(rssiStr, chan)) { + rssiStr = "xxx dB"; } - } void PlutoSDRMIMO::getRxGain(int& gaindB, int chan) @@ -1380,13 +1371,9 @@ void PlutoSDRMIMO::getRxGain(int& gaindB, int chan) return; } - if (m_plutoParams) - { - DevicePlutoSDRBox *plutoBox = m_plutoParams->getBox(); - - if (!plutoBox->getRxGain(gaindB, chan)) { - gaindB = 0; - } + DevicePlutoSDRBox *plutoBox = m_plutoParams ? m_plutoParams->getBox() : nullptr; + if (plutoBox && !plutoBox->getRxGain(gaindB, chan)) { + gaindB = 0; } } @@ -1398,17 +1385,13 @@ void PlutoSDRMIMO::getbbLPRange(quint32& minLimit, quint32& maxLimit) return; } - if (m_plutoParams) + DevicePlutoSDRBox *plutoBox = m_plutoParams ? m_plutoParams->getBox() : nullptr; + if (plutoBox) { - DevicePlutoSDRBox *plutoBox = m_plutoParams->getBox(); - - if (plutoBox) - { - uint32_t min, max; - plutoBox->getbbLPRxRange(min, max); - minLimit = min; - maxLimit = max; - } + uint32_t min, max; + plutoBox->getbbLPRxRange(min, max); + minLimit = min; + maxLimit = max; } } @@ -1420,17 +1403,13 @@ void PlutoSDRMIMO::getLORange(qint64& minLimit, qint64& maxLimit) return; } - if (m_plutoParams) + DevicePlutoSDRBox *plutoBox = m_plutoParams ? m_plutoParams->getBox() : nullptr; + if (plutoBox) { - DevicePlutoSDRBox *plutoBox = m_plutoParams->getBox(); - - if (plutoBox) - { - uint64_t min, max; - plutoBox->getRxLORange(min, max); - minLimit = min; - maxLimit = max; - } + uint64_t min, max; + plutoBox->getRxLORange(min, max); + minLimit = min; + maxLimit = max; } } @@ -1442,13 +1421,9 @@ bool PlutoSDRMIMO::fetchTemperature() return false; } - if (m_plutoParams) - { - DevicePlutoSDRBox *plutoBox = m_plutoParams->getBox(); - - if (plutoBox) { - return plutoBox->fetchTemp(); - } + DevicePlutoSDRBox *plutoBox = m_plutoParams ? m_plutoParams->getBox() : nullptr; + if (plutoBox) { + return plutoBox->fetchTemp(); } return false; @@ -1462,13 +1437,9 @@ float PlutoSDRMIMO::getTemperature() return 0.0; } - if (m_plutoParams) - { - DevicePlutoSDRBox *plutoBox = m_plutoParams->getBox(); - - if (plutoBox) { - return plutoBox->getTemp(); - } + DevicePlutoSDRBox *plutoBox = m_plutoParams ? m_plutoParams->getBox() : nullptr; + if (plutoBox) { + return plutoBox->getTemp(); } return 0.0;