[PATCH 4/4] libfdt: Use VALID_INPUT for FDT_ERR_BADSTATE checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



This error indicates a logic bug in the code calling libfdt, so VALID_DTB
is not really the right check. Update it to use VALID_INPUT instead.

Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx>
Suggested-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
---

 libfdt/fdt.c    | 2 +-
 libfdt/fdt_sw.c | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index 4419204..c28fcc1 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -33,7 +33,7 @@ int32_t fdt_ro_probe_(const void *fdt)
 		}
 	} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
 		/* Unfinished sequential-write blob */
-		if (fdt_size_dt_struct(fdt) == 0)
+		if (!can_assume(VALID_INPUT) && fdt_size_dt_struct(fdt) == 0)
 			return -FDT_ERR_BADSTATE;
 	} else {
 		return -FDT_ERR_BADMAGIC;
diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
index 352193c..26759d5 100644
--- a/libfdt/fdt_sw.c
+++ b/libfdt/fdt_sw.c
@@ -12,7 +12,7 @@
 
 static int fdt_sw_probe_(void *fdt)
 {
-	if (!can_assume(VALID_DTB)) {
+	if (!can_assume(VALID_INPUT)) {
 		if (fdt_magic(fdt) == FDT_MAGIC)
 			return -FDT_ERR_BADSTATE;
 		else if (fdt_magic(fdt) != FDT_SW_MAGIC)
@@ -41,7 +41,7 @@ static int fdt_sw_probe_memrsv_(void *fdt)
 	if (err)
 		return err;
 
-	if (!can_assume(VALID_DTB) && fdt_off_dt_strings(fdt) != 0)
+	if (!can_assume(VALID_INPUT) && fdt_off_dt_strings(fdt) != 0)
 		return -FDT_ERR_BADSTATE;
 	return 0;
 }
@@ -67,7 +67,8 @@ static int fdt_sw_probe_struct_(void *fdt)
 	if (err)
 		return err;
 
-	if (fdt_off_dt_strings(fdt) != fdt_totalsize(fdt))
+	if (!can_assume(VALID_INPUT) &&
+	    fdt_off_dt_strings(fdt) != fdt_totalsize(fdt))
 		return -FDT_ERR_BADSTATE;
 	return 0;
 }
-- 
2.25.0.265.gbab2e86ba0-goog




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux