rf_uhd_generic: fix segfault when accessing device tree

for some reasons the dev tree isn't available on the X310
with UHD4 and the code never checked the return value, causing
a segfault with that combo.
This commit is contained in:
Andre Puschmann 2021-04-28 16:50:05 +02:00
parent 949ce965c7
commit 20075f6f33
1 changed files with 5 additions and 1 deletions

View File

@ -213,9 +213,13 @@ public:
stream_args.channels[i] = i;
}
if (not usrp->get_device()->get_tree()->exists(TREE_DBOARD_RX_FRONTEND_NAME)) {
// Try to get dboard name from property tree
uhd::property_tree::sptr tree = usrp->get_device()->get_tree();
if (tree == nullptr || not tree->exists(TREE_DBOARD_RX_FRONTEND_NAME)) {
// Couldn't find dboard name in property tree
return err;
}
std::string dboard_name = usrp->get_device()->get_tree()->access<std::string>(TREE_DBOARD_RX_FRONTEND_NAME).get();
// Detect if it a AD9361 based device