1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-05-23 08:37:06 -04:00

sdrsrv: fix null-deref in MainServer::addMIMODevice()

addMIMODevice() never assigned m_deviceSets.back()->m_deviceAPI before
dereferencing it via setSampleMIMO(), causing the very first
POST /sdrangel/deviceset?direction=2 against a fresh headless server
to SIGSEGV in DeviceAPI::setSampleMIMO()'s vtable lookup.

DeviceSet's constructor initializes m_deviceAPI to nullptr
(sdrbase/device/deviceset.cpp:38), and the sibling helpers
addSinkDevice() (line 283) and addSourceDevice() (line 323) both
assign the new DeviceAPI* into m_deviceSets.back()->m_deviceAPI
before any later dereference. addMIMODevice() omits this assignment,
so the line that today reads:

    m_mainCore->m_deviceSets.back()->m_deviceAPI->setSampleMIMO(mimo);

dereferences nullptr.

Fix by performing the same assignment as the Sink/Source paths, just
before the createSampleMIMOPluginInstance() call.

Verified against v7.25.1 in a custom headless build
(cicada-sdrangelsrv:7.25.1-mimo) with a LimeSDR-USB:

  - Pre-patch: POST /sdrangel/deviceset?direction=2 -> HTTP 202,
    then immediate SIGSEGV (backtrace top frame
    DeviceAPI::setSampleMIMO -> MainServer::addMIMODevice).
  - Post-patch: POST -> HTTP 202, container healthy, follow-up
    PUT /sdrangel/deviceset/0/device with hwType=LimeSDR
    direction=2 -> HTTP 202, deviceset reports the LimeSDR
    correctly bound as a MIMO device.
This commit is contained in:
Zane (RainCicada) 2026-05-21 21:40:04 -05:00
parent f8eb645546
commit 87e1cabfca

View File

@ -377,6 +377,8 @@ void MainServer::addMIMODevice()
deviceAPI->setHardwareUserArguments(userArgs);
}
m_mainCore->m_deviceSets.back()->m_deviceAPI = deviceAPI;
DeviceSampleMIMO *mimo = deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance(
deviceAPI->getSamplingDeviceId(), deviceAPI);
m_mainCore->m_deviceSets.back()->m_deviceAPI->setSampleMIMO(mimo);