summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoff Levand <geoff@infradead.org>2013-10-03 20:19:34 +0000
committerSimon Horman <horms@verge.net.au>2013-10-04 09:01:01 +0900
commit6bd7a0e8caa98eea328a8491ce099f9314c2af44 (patch)
treef42d0bae26362a3201350ad96376a5e4bb26ae69
parente9df14dcef5bde6e77760243783c07b4533ee7dc (diff)
downloadkexec-tools-6bd7a0e8caa98eea328a8491ce099f9314c2af44.tar.gz
kexec: Handle read errors in fs2dt setup
The putnode() routine in fs2dt.c was not checking for errors returned from calls to read(). Add checks for these errors and abort the setup of printing from purgatory if the checks fail. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/fs2dt.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
index 98d6cb4..242a15e 100644
--- a/kexec/fs2dt.c
+++ b/kexec/fs2dt.c
@@ -639,6 +639,11 @@ static void putnode(void)
}
result = read(fd, buff, statbuf.st_size);
close(fd);
+ if (result <= 0) {
+ printf("Unable to read %s, printing from purgatory is diabled\n",
+ filename);
+ goto no_debug;
+ }
strncpy(filename, "/proc/device-tree/", MAXPATH);
strncat(filename, buff, MAXPATH);
strncat(filename, "/compatible", MAXPATH);
@@ -661,7 +666,8 @@ static void putnode(void)
goto no_debug;
}
result = read(fd, buff, statbuf.st_size);
- if (!strcmp(buff, "hvterm1") || !strcmp(buff, "hvterm-protocol"))
+ if (result && (!strcmp(buff, "hvterm1")
+ || !strcmp(buff, "hvterm-protocol")))
my_debug = 1;
close(fd);
free(buff);