summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Young <dyoung@redhat.com>2016-02-26 19:57:55 +0800
committerSimon Horman <horms@verge.net.au>2016-03-02 09:14:25 +0900
commit7c53754e5da8bd83dafbb5c07a9ad368b1a83f61 (patch)
tree5f4578f4ad43d3bb43926478da4de650404df251
parent61cfab4e2ce02f2f404130262caa89b9d03f685c (diff)
kexec/fs2dt.c: wrong dt node fix
2nd kernel hangs early because of a regression caused by below commit: commit 68262155d8c661586b809bc5301a7dff1c378137 Author: Andrew Jones <drjones@redhat.com> Date: Fri Nov 20 12:31:53 2015 -0500 kexec/fs2dt: cleanup pathname putnode() will add the trailing '/', avoid having two. Also pathstart is unused, get rid of it. Signed-off-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au> The actual purpose of the commit is to avoid double slash in pathname. But unfortunately in function putnode() we have below magics to get the node name: basename = strrchr(pathname,'/') + 1; ... strcpy((void *)dt, *basename ? basename : ""); ... strcat(pathname, "/"); We treat none zero basename as a node name, then concat a slash to open the directory for later property handling. pathname originally was "/proc/device-tree/" so for the first run of putnode it will cause double slashes. With the commit above mentioned there are no double slashes but we will copy "device-tree" to dt. Thus kexec kernel is not happy.. Instead let's fix it by only concating slash when the basenanme is not empty and restore the initial value of pathname as "/proc/device-tree/" Note: I only reproduce the issue with loading older kernel like 3.10 in RHEL. I do not see the problem in new kernels in Fedora. Signed-off-by: Dave Young <dyoung@redhat.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/fs2dt.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
index b3c209b..6ed2399 100644
--- a/kexec/fs2dt.c
+++ b/kexec/fs2dt.c
@@ -577,7 +577,8 @@ static void putnode(void)
strcpy((void *)dt, *basename ? basename : "");
dt += ((plen + 4)/4);
- strcat(pathname, "/");
+ if (*basename)
+ strcat(pathname, "/");
dn = pathname + strlen(pathname);
putprops(dn, namelist, numlist);
@@ -804,7 +805,7 @@ static void add_boot_block(char **bufp, off_t *sizep)
void create_flatten_tree(char **bufp, off_t *sizep, const char *cmdline)
{
- strcpy(pathname, "/proc/device-tree");
+ strcpy(pathname, "/proc/device-tree/");
dt_cur_size = INIT_TREE_WORDS;
dt_base = malloc(dt_cur_size*4);