From: Masami Hiramatsu (Google) <[email protected]> BOOTCONFIG_FOOTER_SIZE was defined locally in tools/bootconfig/main.c. Move it to include/linux/bootconfig.h so that it can be shared with the kernel and user-space tools. Also, use it in init/main.c instead of the hardcoded (BOOTCONFIG_MAGIC_LEN + 8) expression when checking the initrd size.
Suggested-by: Sang-Heon Jeon <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]> --- Changes in v2: - Newly added. --- include/linux/bootconfig.h | 4 ++++ init/main.c | 2 +- tools/bootconfig/main.c | 4 ---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/bootconfig.h b/include/linux/bootconfig.h index deda507500da..6f23ec11baab 100644 --- a/include/linux/bootconfig.h +++ b/include/linux/bootconfig.h @@ -27,6 +27,10 @@ bool __init cmdline_has_extra_options(void); #define BOOTCONFIG_ALIGN (1 << BOOTCONFIG_ALIGN_SHIFT) #define BOOTCONFIG_ALIGN_MASK (BOOTCONFIG_ALIGN - 1) +/* Bootconfig footer is [size][csum][BOOTCONFIG_MAGIC]. */ +#define BOOTCONFIG_FOOTER_SIZE \ + (sizeof(uint32_t) * 2 + BOOTCONFIG_MAGIC_LEN) + /** * xbc_calc_checksum() - Calculate checksum of bootconfig * @data: Bootconfig data. diff --git a/init/main.c b/init/main.c index 16749bb7a219..37168bd68126 100644 --- a/init/main.c +++ b/init/main.c @@ -278,7 +278,7 @@ static void * __init get_boot_config_from_initrd(size_t *_size) int i; if (!initrd_end || initrd_end < initrd_start || - initrd_end - initrd_start < BOOTCONFIG_MAGIC_LEN + 8) + initrd_end - initrd_start < BOOTCONFIG_FOOTER_SIZE) return NULL; data = (char *)initrd_end - BOOTCONFIG_MAGIC_LEN; diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c index 652e491b9c33..d4aa96da970e 100644 --- a/tools/bootconfig/main.c +++ b/tools/bootconfig/main.c @@ -17,10 +17,6 @@ #define pr_err(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) -/* Bootconfig footer is [size][csum][BOOTCONFIG_MAGIC]. */ -#define BOOTCONFIG_FOOTER_SIZE \ - (sizeof(uint32_t) * 2 + BOOTCONFIG_MAGIC_LEN) - static void show_xbc_error(const char *data, const char *msg, int pos) { int lin = 1, col, i;
