With Chrome OS the kernel setup block is stored in a separate place from
the kernel, so it is not possible to access the kernel version string.
At present, garbage is printed.
Add a sanity check to avoid this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
#include <asm/arch/timestamp.h>
#endif
#include <linux/compiler.h>
+#include <linux/ctype.h>
#include <linux/libfdt.h>
/*
{
struct setup_header *hdr = ¶ms->hdr;
int bootproto;
+ const char *s, *end;
bootproto = get_boot_protocol(hdr, false);
if (bootproto < 0x0200 || hdr->setup_sects < 15)
return NULL;
+ /* sanity-check the kernel version in case it is missing */
+ for (s = kernel_base + hdr->kernel_version + 0x200, end = s + 0x100; *s;
+ s++) {
+ if (!isprint(*s))
+ return NULL;
+ }
+
return kernel_base + hdr->kernel_version + 0x200;
}