diff --git a/libpdbg/device.c b/libpdbg/device.c
index cb25c82..452e288 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -749,10 +749,14 @@ skip:
 
 bool pdbg_targets_init(void *fdt)
 {
+	struct pdbg_dtb dtb = { .system = NULL, };
+
 	if (!fdt)
-		fdt = pdbg_default_dtb();
+		pdbg_default_dtb(&dtb);
+	else
+		dtb.system = fdt;
 
-	if (!fdt) {
+	if (!dtb.system) {
 		pdbg_log(PDBG_ERROR, "Could not find a system device tree\n");
 		return false;
 	}
@@ -762,7 +766,7 @@ bool pdbg_targets_init(void *fdt)
 	if (!pdbg_dt_root)
 		return false;
 
-	dt_expand(pdbg_dt_root, fdt);
+	dt_expand(pdbg_dt_root, dtb.system);
 
 	pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root);
 	return true;
diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c
index e19ce95..3d0f9b4 100644
--- a/libpdbg/dtb.c
+++ b/libpdbg/dtb.c
@@ -78,20 +78,23 @@ static enum pdbg_backend default_backend(void)
 
 /* Try and determine what system type we are on by reading
  * /proc/cpuinfo */
-static void *ppc_target(void)
+static void ppc_target(struct pdbg_dtb *dtb)
 {
 	const char *pos = NULL;
 	char line[256];
 	FILE *cpuinfo;
 
-	if (!strcmp(pdbg_backend_option, "p8"))
-		return &_binary_p8_host_dtb_o_start;
-	else if (!strcmp(pdbg_backend_option, "p9"))
-		return &_binary_p9_host_dtb_o_start;
+	if (!strcmp(pdbg_backend_option, "p8")) {
+		dtb->system = &_binary_p8_host_dtb_o_start;
+		return;
+	} else if (!strcmp(pdbg_backend_option, "p9")) {
+		dtb->system = &_binary_p9_host_dtb_o_start;
+		return;
+	}
 
 	cpuinfo = fopen("/proc/cpuinfo", "r");
 	if (!cpuinfo)
-		return NULL;
+		return;
 
 	while ((pos = fgets(line, sizeof(line), cpuinfo)))
 		if (strncmp(line, "cpu", 3) == 0)
@@ -101,32 +104,31 @@ static void *ppc_target(void)
 	if (!pos) {
 		/* Got to EOF without a break */
 		pdbg_log(PDBG_ERROR, "Unable to parse /proc/cpuinfo\n");
-		return NULL;
+		return;
 	}
 
 	pos = strchr(line, ':');
 	if (!pos || (*(pos + 1) == '\0')) {
 		pdbg_log(PDBG_ERROR, "Unable to parse /proc/cpuinfo\n");
-		return NULL;
+		return;
 	}
 
 	pos += 2;
 
 	if (strncmp(pos, "POWER8", 6) == 0) {
 		pdbg_log(PDBG_INFO, "Found a POWER8 PPC host system\n");
-		return &_binary_p8_host_dtb_o_start;
+		dtb->system = &_binary_p8_host_dtb_o_start;
 	}
 
 	if (strncmp(pos, "POWER9", 6) == 0) {
 		pdbg_log(PDBG_INFO, "Found a POWER9 PPC host system\n");
-		return &_binary_p9_host_dtb_o_start;
+		dtb->system = &_binary_p9_host_dtb_o_start;
 	}
 
 	pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos);
-	return NULL;
 }
 
-static void *bmc_target(void)
+static void bmc_target(struct pdbg_dtb *dtb)
 {
 	FILE *cfam_id_file;
 	uint32_t cfam_id = 0;
@@ -147,7 +149,7 @@ static void *bmc_target(void)
 		free(path);
 		if (!cfam_id_file) {
 			pdbg_log(PDBG_ERROR, "Unabled to open CFAM ID file\n");
-			return NULL;
+			return;
 		}
 
 		rc = fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id);
@@ -169,18 +171,17 @@ static void *bmc_target(void)
 	switch(chip_id) {
 	case CHIP_ID_P9:
 		pdbg_log(PDBG_INFO, "Found a POWER9 OpenBMC based system\n");
-		return &_binary_p9_kernel_dtb_o_start;
+		dtb->system = &_binary_p9_kernel_dtb_o_start;
 		break;
 
 	case CHIP_ID_P8:
 	case CHIP_ID_P8P:
 		pdbg_log(PDBG_INFO, "Found a POWER8/8+ OpenBMC based system\n");
-		return &_binary_p8_kernel_dtb_o_start;
+		dtb->system = &_binary_p8_kernel_dtb_o_start;
 		break;
 
 	default:
 		pdbg_log(PDBG_ERROR, "Unrecognised Chip ID register 0x%08" PRIx32 "\n", chip_id);
-		return NULL;
 	}
 }
 
@@ -235,50 +236,56 @@ const char *pdbg_get_backend_option(void)
 
 /* Determines what platform we are running on and returns a pointer to
  * the fdt that is most likely to work on the system. */
-void *pdbg_default_dtb(void)
+void pdbg_default_dtb(struct pdbg_dtb *dtb)
 {
-	char *dtb = getenv("PDBG_DTB");
+	char *fdt = getenv("PDBG_DTB");
 
-	if (dtb)
-		return mmap_dtb(dtb);
+	*dtb = (struct pdbg_dtb) {
+		.system = NULL,
+	};
+
+	if (fdt) {
+		dtb->system = mmap_dtb(fdt);
+		return;
+	}
 
 	if (!pdbg_backend)
 		pdbg_backend = default_backend();
 
 	switch(pdbg_backend) {
 	case PDBG_BACKEND_HOST:
-		return ppc_target();
+		ppc_target(dtb);
 		break;
 
 	case PDBG_BACKEND_I2C:
 		/* I2C is only supported on POWER8 */
 		pdbg_log(PDBG_INFO, "Found a POWER8 AMI BMC based system\n");
-		return &_binary_p8_i2c_dtb_o_start;
+		dtb->system = &_binary_p8_i2c_dtb_o_start;
 		break;
 
 	case PDBG_BACKEND_KERNEL:
-		return bmc_target();
+		bmc_target(dtb);
 		break;
 
 	case PDBG_BACKEND_FSI:
 		if (!pdbg_backend_option) {
 			pdbg_log(PDBG_ERROR, "No device type specified\n");
 			pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n");
-			return NULL;
+			return;
 		}
 
 		if (!strcmp(pdbg_backend_option, "p8"))
-			return &_binary_p8_fsi_dtb_o_start;
+			dtb->system = &_binary_p8_fsi_dtb_o_start;
 		else if (!strcmp(pdbg_backend_option, "p9w"))
-			return &_binary_p9w_fsi_dtb_o_start;
+			dtb->system = &_binary_p9w_fsi_dtb_o_start;
 		else if (!strcmp(pdbg_backend_option, "p9r"))
-			return &_binary_p9r_fsi_dtb_o_start;
+			dtb->system = &_binary_p9r_fsi_dtb_o_start;
 		else if (!strcmp(pdbg_backend_option, "p9z"))
-			return &_binary_p9z_fsi_dtb_o_start;
+			dtb->system = &_binary_p9z_fsi_dtb_o_start;
 		else {
 			pdbg_log(PDBG_ERROR, "Invalid device type specified\n");
 			pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n");
-			return NULL;
+			return;
 		}
 
 		break;
@@ -287,17 +294,17 @@ void *pdbg_default_dtb(void)
 		if (!pdbg_backend_option) {
 			pdbg_log(PDBG_ERROR, "No device type specified\n");
 			pdbg_log(PDBG_ERROR, "Use p8@<server> or p9@<server>\n");
-			return NULL;
+			return;
 		}
 
 		if (!strncmp(pdbg_backend_option, "p8", 2))
-			return &_binary_p8_cronus_dtb_o_start;
+			dtb->system = &_binary_p8_cronus_dtb_o_start;
 		else if (!strncmp(pdbg_backend_option, "p9", 2))
-			return &_binary_p9_cronus_dtb_o_start;
+			dtb->system = &_binary_p9_cronus_dtb_o_start;
 		else {
 			pdbg_log(PDBG_ERROR, "Invalid device type specified\n");
 			pdbg_log(PDBG_ERROR, "Use p8@<server> or p9@<server>\n");
-			return NULL;
+			return;
 		}
 
 		break;
@@ -307,7 +314,7 @@ void *pdbg_default_dtb(void)
 		/* Fall through */
 
 	case PDBG_BACKEND_FAKE:
-		return &_binary_fake_dtb_o_start;
+		dtb->system = &_binary_fake_dtb_o_start;
 		break;
 	}
 }
diff --git a/libpdbg/target.h b/libpdbg/target.h
index 0422406..4f1721e 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -53,6 +53,10 @@ struct pdbg_target {
 	struct pdbg_target *vnode;
 };
 
+struct pdbg_dtb {
+	void *system;
+};
+
 struct pdbg_target *get_parent(struct pdbg_target *target, bool system);
 struct pdbg_target *target_parent(const char *klass, struct pdbg_target *target, bool system);
 struct pdbg_target *require_target_parent(const char *klass, struct pdbg_target *target, bool system);
@@ -64,7 +68,7 @@ bool pdbg_target_is_class(struct pdbg_target *target, const char *class);
 extern struct list_head empty_list;
 extern struct list_head target_classes;
 
-void *pdbg_default_dtb(void);
+void pdbg_default_dtb(struct pdbg_dtb *pdtb);
 const char *pdbg_get_backend_option(void);
 
 struct sbefifo *pib_to_sbefifo(struct pdbg_target *target);
