Browse Source

modemdvb: Fix data races on input sample rate

Fix Coverity CIDs 657466, 657471, and 657508 by protecting
reads of m_inputRate with m_ofdmMutex. Copy the rate while
holding the mutex and use the local copy outside the
critical section.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.1.0
Robin Getz 4 weeks ago
parent
commit
b2e6a5cc8a
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 13
      modemdvb/dvbtreceiver.cpp

13
modemdvb/dvbtreceiver.cpp

@ -103,6 +103,8 @@ void Receiver::reset() @@ -103,6 +103,8 @@ void Receiver::reset()
m_ofdm.reset();
m_clockUpdateSymbols = 0;
std::vector<double> notches;
double inputRate;
{
std::lock_guard<std::mutex> lock(m_ofdmMutex);
m_ofdmStatus = m_ofdm.getStatus();
@ -120,9 +122,11 @@ void Receiver::reset() @@ -120,9 +122,11 @@ void Receiver::reset()
}
m_notchesQueued = m_notchFrequencies;
notches = m_notchesQueued;
inputRate = m_inputRate;
}
m_ofdm.setNotches(m_notchesQueued, m_inputRate); // The demodulator thread isn't running
m_ofdm.setNotches(notches, inputRate); // The demodulator thread isn't running
if (m_threaded)
{
@ -334,7 +338,12 @@ void Receiver::correctClock() @@ -334,7 +338,12 @@ void Receiver::correctClock()
m_resampling = true;
m_resampler.setRatioCorrection(1.0);
m_resampler.configure(m_inputRate, m_outputRate, 0.4165 * m_outputRate);
double inputRate;
{
std::lock_guard<std::mutex> lock(m_ofdmMutex);
inputRate = m_inputRate;
}
m_resampler.configure(inputRate, m_outputRate, 0.4165 * m_outputRate);
m_resampler.prime(m_lastInput);
setRatioCorrection(1.0 - ppm * 1e-6); // The measurement is accurate, so start with all of it
return;

Loading…
Cancel
Save