From 20075f6f331f836bddc4e00be371c19b2f86a956 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 28 Apr 2021 16:50:05 +0200 Subject: [PATCH] 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. --- lib/src/phy/rf/rf_uhd_generic.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/phy/rf/rf_uhd_generic.h b/lib/src/phy/rf/rf_uhd_generic.h index 4d63509a4..bcf268d71 100644 --- a/lib/src/phy/rf/rf_uhd_generic.h +++ b/lib/src/phy/rf/rf_uhd_generic.h @@ -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(TREE_DBOARD_RX_FRONTEND_NAME).get(); // Detect if it a AD9361 based device