diff mbox series

[2/2] libpdbg: Add explicit check for library initialisation

Message ID 20200422021731.112666-2-amitay@ozlabs.org
State Accepted
Headers show
Series [1/2] libpdbg: Update documentation for pdbg_targets_init() | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (6ae2ba655ca5e24b403a33bf15dff7261d3e7052)
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Amitay Isaacs April 22, 2020, 2:17 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/device.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libpdbg/device.c b/libpdbg/device.c
index 219569e..80a8287 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -709,6 +709,11 @@  bool pdbg_targets_init(void *fdt)
 {
 	struct pdbg_dtb *dtb;
 
+	if (pdbg_dt_root) {
+		pdbg_log(PDBG_ERROR, "pdbg_targets_init() must be called only once\n");
+		return false;
+	}
+
 	dtb = pdbg_default_dtb(fdt);
 
 	if (!dtb) {