summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBhupesh Sharma <bhsharma@redhat.com>2018-12-17 00:46:54 +0530
committerSimon Horman <horms@verge.net.au>2019-01-09 13:22:46 +0100
commit5570b42444661e212015abaca35b4dc698b9bb97 (patch)
treebfbdde307fe63e4e8132aa457b210626a7a5f20f
parent9dcf363f509a1fa12a4d0d790a309a77c50aacaa (diff)
downloadkexec-tools-5570b42444661e212015abaca35b4dc698b9bb97.tar.gz
kexec/dt-ops.c: Fix adding '/chosen' node for cases where it is not available in dtb passed via --dtb option
While calling 'kexec -l', in case we are passed a .dtb using --dtb option which doesn't contain a '/chosen' node, we try to create the '/chosen' node and add bootargs to this node. Currently the 'dt-ops.c' code is buggy as it passes '-FDT_ERR_NOTFOUND' to 'fdt_add_subnode()', which leads to the following error: # kexec -d --load Image --append 'debug' --dtb rk3399-sapphire.dtb <..snip..> dtb_set_property: fdt_add_subnode failed: FDT_ERR_NOTFOUND kexec: Set device tree bootargs failed. get_cells_size: #address-cells:2 #size-cells:2 cells_size_fitted: 0-0 cells_size_fitted: 0-0 setup_2nd_dtb: no kaslr-seed found This patch passes the correct nodeoffset value to 'fdt_add_subnode()', which fixes this issue: # kexec -d -l Image --append 'debug' --dtb rk3399-sapphire.dtb <..snip..> get_cells_size: #address-cells:2 #size-cells:2 cells_size_fitted: 0-0 cells_size_fitted: 0-0 setup_2nd_dtb: no kaslr-seed found Reported-by: Vicente Bergas <vicencb@gmail.com> Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/dt-ops.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/kexec/dt-ops.c b/kexec/dt-ops.c
index f15174c3..bdc16dc8 100644
--- a/kexec/dt-ops.c
+++ b/kexec/dt-ops.c
@@ -80,15 +80,16 @@ int dtb_set_property(char **dtb, off_t *dtb_size, const char *node,
}
nodeoffset = fdt_path_offset(new_dtb, node);
-
+
if (nodeoffset == -FDT_ERR_NOTFOUND) {
- result = fdt_add_subnode(new_dtb, nodeoffset, node);
+ result = fdt_add_subnode(new_dtb, 0, node);
if (result < 0) {
dbgprintf("%s: fdt_add_subnode failed: %s\n", __func__,
fdt_strerror(result));
goto on_error;
}
+ nodeoffset = result;
} else if (nodeoffset < 0) {
dbgprintf("%s: fdt_path_offset failed: %s\n", __func__,
fdt_strerror(nodeoffset));