[PATCH] dom0less: Remove redundant magic check in 'check_partial_fdt()'

Dmytro Prokopchuk1 posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/f624c6fd2e63ce92d764519922ec5cf39152fa91.1762772330.git.dmytro._5Fprokopchuk1@epam.com
xen/common/device-tree/dom0less-build.c | 6 ------
1 file changed, 6 deletions(-)
[PATCH] dom0less: Remove redundant magic check in 'check_partial_fdt()'
Posted by Dmytro Prokopchuk1 1 month ago
The function 'check_partial_fdt()' performs an explicit check for the FDT
magic number (FDT_MAGIC) before calling 'fdt_check_header(). This check is
redundant, because 'fdt_check_header()' includes checking the magic number.

Remove the redundant check to simplify the code and rely on the library
function to perform header validation.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
 xen/common/device-tree/dom0less-build.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tree/dom0less-build.c
index 9fd004c42a..2600350a3c 100644
--- a/xen/common/device-tree/dom0less-build.c
+++ b/xen/common/device-tree/dom0less-build.c
@@ -359,12 +359,6 @@ static int __init check_partial_fdt(void *pfdt, size_t size)
 {
     int res;
 
-    if ( fdt_magic(pfdt) != FDT_MAGIC )
-    {
-        dprintk(XENLOG_ERR, "Partial FDT is not a valid Flat Device Tree");
-        return -EINVAL;
-    }
-
     res = fdt_check_header(pfdt);
     if ( res )
     {
-- 
2.43.0
Re: [PATCH] dom0less: Remove redundant magic check in 'check_partial_fdt()'
Posted by Orzel, Michal 1 month ago

On 10/11/2025 11:59, Dmytro Prokopchuk1 wrote:
> The function 'check_partial_fdt()' performs an explicit check for the FDT
> magic number (FDT_MAGIC) before calling 'fdt_check_header(). This check is
> redundant, because 'fdt_check_header()' includes checking the magic number.
> 
> Remove the redundant check to simplify the code and rely on the library
> function to perform header validation.
> 
> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal