Browse Source

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 <rgetz503@gmail.com>
chirpmodem-v8.1.0
Robin Getz 4 weeks ago
parent
commit
3dd928ab3b
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 89
      plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp

89
plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp

@ -680,11 +680,11 @@ bool PlutoSDRMIMO::applySettings(const PlutoSDRMIMOSettings& settings, const QLi @@ -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 @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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() @@ -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() @@ -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;

Loading…
Cancel
Save